Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am able to send emails successfully from LocalHost. After hosting my website i am unable to send.

The following is the error:
XML
System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0



Below is the code:(Code Behind)

public void SendMail(string ToMail, string subject, string Message)
{

MailMessage mailMsg = new MailMessage();
mailMsg.To.Add(ToMail);
mailMsg.Subject = subject;
mailMsg.IsBodyHtml = false;
mailMsg.Body = Message;


SmtpClient smtpclient = new SmtpClient();
smtpclient.EnableSsl = true;
smtpclient.UseDefaultCredentials = true;
smtpclient.Send(mailMsg);
}



Web.config:



<system.net>
<mailSettings>
<smtp from="localtalentmail@gmail.com" deliveryMethod="Network">
<network host="smtp.gmail.com" port="587" password="**********" userName="mygmailId@gmail.com"/>
</smtp>
</mailSettings>
</system.net>



pls help me to solve this.
Posted

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900