Quantcast
Channel: Sending email error - SMTP Server requires a secure connection 5.5.1
Viewing all articles
Browse latest Browse all 11

Sending email error - SMTP Server requires a secure connection 5.5.1

$
0
0

I have this in my webconfig:

<mailSettings><smtp from="mygmailadd@gmail.com"><network host="smtp.gmail.com" password="gmailpassword" port="587"
userName="mygmailadd@gmail.com" /></smtp></mailSettings>



This is  my contact form code:

protected void Button1_Click(object sender, EventArgs e)
    {
        // Create a message and set up the recipients.
        SmtpClient smtpClient = new SmtpClient();
        MailMessage message = new MailMessage();
        message.To.Add("mymail@domain.com");
        message.Subject = "Form - ";
        message.IsBodyHtml = true;
        message.Priority = MailPriority.High;
        message.Body = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">";
        message.Body += "<HTML><HEAD><META http-equiv=Content-Type content=\"text/html; charset=iso-8859-1\">";
        message.Body += "</HEAD><BODY>";

        message.Body += "<table border='1'><tr><td>Textbox1.Text</td><td>Textbox2.Text</td></tr><tr><td>Textbox3.Text</td><td>Textbox4.Text</td></tr></table>";
        message.Body += "</BODY></HTML>";

               // Send the message.
        smtpClient.EnableSsl = true;
        smtpClient.Send(message);
}



The problem is, when I press "send email" button, I get error following error even thought when I have enableSSL = true in my code ?

How to solve this problem ?

Error

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



Viewing all articles
Browse latest Browse all 11

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>