Home > DeveloperSection > Forums > The SMTP server requires a secure connection when i try to send an email
jayprakash sharma
jayprakash sharma

Total Post:117

Posted on    September-29-2014 12:38 AM

 C# C# 

 1 Reply(s)
 648  View(s)
Rate this:

I create a mail class to send emails.


public void SendEmail(string subject, string messageBody, string toAddress)


    MailMessage mail = new MailMessage();



    mail.From = new MailAddress("noreply3ncra@gmail.com");

    mail.Subject = subject;

    string Body = messageBody;

    mail.Body = Body;

    mail.IsBodyHtml = true;

    SmtpClient smtp = new SmtpClient();

    smtp.UseDefaultCredentials = false;


    smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address

    smtp.Credentials = new System.Net.NetworkCredential

         ("noreply3ncra@gmail.com", "********");

    //Or your Smtp Email ID and Password

    smtp.EnableSsl = true;



But I got this error:


The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.


So I have to sign into Gmail and enter the captcha code and after this every thing is going to be ok.


What should I do?

Sumit Kesarwani

Total Post:378

Posted on    September-29-2014 1:01 AM

Hi jay, 

Add port no also to your code as:

 smtp.Port = 587;

Don't want to miss updates? Please click the below button!

Follow MindStick