Search This Blog

Thursday, May 24, 2018

Send Email using Gmail SMTP Server - C#

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 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 = "";

            NetworkCredential authinfo = new NetworkCredential("", "testPassword");
            smtp.UseDefaultCredentials = false;
            smtp.Credentials = authinfo;
            smtp.EnableSsl = true;
            smtp.Send("", "", "test", "testbody");


No comments:

Post a Comment