I am trying to send an email with security code with ASP.NET
int code = random.Next(1000, 9999);
string text = "Your security code is "+ code +" ";
MailMessage message = new MailMessage("//myemail//", Email.Text.Trim(),"Changing Password", text);
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient("//smtp host//",//smtp port// );
client.EnableSsl = true;
client.Credentials = new NetworkCredential("//myemail//","//mypassword//");
client.Send(message);
If I use gmail it throws Authentication 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 Authentication Required. Learn more at'
And if I use my other email it throws this after 2-3 minutes:
System.Net.Mail.SmtpException: 'The operation has timed out.'