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
You should disallow less secure apps to access your google account.
to do:
https://myaccount.google.com/lesssecureapps
I'm a google apps for business subscriber and I spend the last couple hours just dealing with this, even after having all the correct settings (smtp, port, enableSSL, etc). Here's what worked for me and the web sites that were throwing the 5.5.1 error when trying to send an email:
After doing this my email forms from the website were working again. Good luck!
Hi I had the same issue,
what I've done to solve it. is to turn on the less secure app. after connecting to my gmail account. I entered this link: https://www.google.com/settings/security/lesssecureapps
Then I turn on the secure app and, and the it worked. it has been said also above
Just follow the step in the google email and enable less secure apps.
This generally happens when you try login from different time zone or IP Address Computer. Your production server and the mail id you have used both are in different time zone. Choose either of these two solutions:
1) Log in to production server via remote access, and sign in to gmail once with your credentials. They will ask for the confirmation, confirm it and log out.
Or 2) log in gmail to your local computer, Follow this Link and choose review this activity and take proper actions.
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