SMTP Server: Authentication the Server Response was 5.5.1 Authentication required in gmail
First login into Gmail Account from which
Gmail credentials are you using to send email.
Now go to Gmail
Settings Feature, it comes in your Gmail Inbox on right side.
Eanble to Security Feature
Now click on Gmail
Setting Feature, move to security feature or alternatively can hit/paste this
URL in your browser https://www.google.com/settings/security/lesssecureapps where
you can see settings.
Access for less secure apps
1.
Turn off
(default)
2.
Turn On
using System.Net;
using System.Net.Mail;
static void Main(string[] args)
{
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
NetworkCredential authinfo = new NetworkCredential("test@gmail.com", "testPassword");
smtp.UseDefaultCredentials = false;
smtp.Credentials = authinfo;
smtp.EnableSsl = true;
smtp.Send("testfrom@gmail.com", "testTo@gmail.com", "test", "testbody");
Console.WriteLine("Sent");
Console.ReadLine();
}
No comments:
Post a Comment