hata mesajı
the smtp server requires a secure connection or the client was not authenticated. the server response was 5.1.1 Authentication Required.
kodlar:
private static readonly string username = ConfigurationManager.AppSettings["username"];
private static readonly string password = ConfigurationManager.AppSettings["password"];
public void SendMail(string to, string from, string subject, string content)
{
this.content = content;
this.from = from;
this.subject = subject;
this.to = to;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential(username, password);
MailMessage mail = new MailMessage(new MailAddress(from, "admin"), new MailAddress(to, "üye"));
mail.Subject = this.subject;
mail.Body = this.content;
mail.IsBodyHtml = true;
smtp.Send(mail);
}
the smtp server requires a secure connection or the client was not authenticated. the server response was 5.1.1 Authentication Required.
kodlar:
private static readonly string username = ConfigurationManager.AppSettings["username"];
private static readonly string password = ConfigurationManager.AppSettings["password"];
public void SendMail(string to, string from, string subject, string content)
{
this.content = content;
this.from = from;
this.subject = subject;
this.to = to;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential(username, password);
MailMessage mail = new MailMessage(new MailAddress(from, "admin"), new MailAddress(to, "üye"));
mail.Subject = this.subject;
mail.Body = this.content;
mail.IsBodyHtml = true;
smtp.Send(mail);
}