I was create sample email sender using c# but it shows an error is:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
mail.To.Add("[email protected]");
mail.From = new MailAddress("[email protected]", "Test Mail !", System.Text.Encoding.UTF8);
mail.Subject = "Test Mail";
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.Body = "Test message";
mail.BodyEncoding = System.Text.Encoding.UTF8;
mail.IsBodyHtml = true;
mail.Priority = MailPriority.High;
SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential("[email protected]", "password");
client.Port = 587;
client.Host = "smtp.gmail.com";
client.EnableSsl = true;
client.UseDefaultCredentials = true;
client.Send(mail);
Web config:
<system.net>
<mailSettings>
<smtp from="[email protected]">
<network host="smtp.gmail.com" password="password"
port="587" userName="[email protected]" />
</smtp>
</mailSettings>
</system.net>