Hi,
I am able to send emails successfully from LocalHost. After hosting my website i am unable to send.
The following is the error:
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>