I got this following error “The SMTP server requires a secure connection or the client was not authenticated. The server response was:5.5.1 authentication Required” while attempting to send mail using asp.net c# (i.e Google authentication required).
Solution to gmail server error:
Case 1:Please enter the correct password!. Otherwise,It may happen SMTP server error, due to the invalid password.
Case 2: Google may block the sign in attempt due modern security standards. You need to enable the following features. Login into your google account and go to:
https://www.google.com/settings/security/lesssecureapps
If you want to use, turn on the less secure access.
c# send mail coding,
using (MailMessage mail = new MailMessage())
{
mail.From = new MailAddress("EMAILID@gmail.com"); //secureserver email settings
mail.To.Add("somebody@domain.com"); //sender emailID
mail.Subject = "Greetings";
mail.Body = "<h1>Welcome User</h1>";
mail.IsBodyHtml = true;
mail.Attachments.Add(new Attachment("C:\\book1.zip"));
using (SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587))
{
smtp.Credentials = new System.Net.NetworkCredential("EMAILID@gmail.com", "password"); //secureserver settings
smtp.EnableSsl = true;
smtp.Send(mail);
}
}
Post your comments / questions
Recent Article
- How to create custom 404 error page in Django?
- Requested setting INSTALLED_APPS, but settings are not configured. You must either define..
- ValueError:All arrays must be of the same length - Python
- Check hostname requires server hostname - SOLVED
- How to restrict access to the page Access only for logged user in Django
- Migration admin.0001_initial is applied before its dependency admin.0001_initial on database default
- Add or change a related_name argument to the definition for 'auth.User.groups' or 'DriverUser.groups'. -Django ERROR
- Addition of two numbers in django python
Related Article