I am using following code to send email. The Code works correctly in my local Machine. But on Production server i am getting the error message
var fromAddres
What worked for me was to activate the option for less secure apps (I am using VB.NET)
Public Shared Sub enviaDB(ByRef body As String, ByRef file_location As String)
Dim mail As New MailMessage()
Dim SmtpServer As New SmtpClient("smtp.gmail.com")
mail.From = New MailAddress("from@gmail.com")
mail.[To].Add("to@gmail.com")
mail.Subject = "subject"
mail.Body = body
Dim attachment As System.Net.Mail.Attachment
attachment = New System.Net.Mail.Attachment(file_location)
mail.Attachments.Add(attachment)
SmtpServer.Port = 587
SmtpServer.Credentials = New System.Net.NetworkCredential("user", "password")
SmtpServer.EnableSsl = True
SmtpServer.Send(mail)
End Sub
So log in to your account and then go to google.com/settings/security/lesssecureapps