0
獲得一個忘記密碼鏈接
// send Email
string toEmailAddress = dt.Rows[0][4].ToString();
string Username = dt.Rows[0][1].ToString();
string EmailBody = "Hi "+Username+ "<br/> click the link below to reset your password<br/> http://localhost:51583/RecoveryPass.aspx?Uid="+myGUID;
MailMessage PassRecMail = new MailMessage("[email protected]",toEmailAddress);
PassRecMail.Body = EmailBody;
PassRecMail.IsBodyHtml = true;
PassRecMail.Subject = "Reset Password";
SmtpClient SMTP = new SmtpClient();
SMTP.Port = 587;
SMTP.Host = "smtp.gmail.com";
SMTP.EnableSsl = true;
SMTP.UseDefaultCredentials = false;
SMTP.DeliveryMethod = SmtpDeliveryMethod.Network;
SMTP.Credentials = new NetworkCredential()
{
UserName= "[email protected]",
Password= "yourGmailPassword"
};
SMTP.UseDefaultCredentials = false;
SMTP.Send(PassRecMail);
我收到此錯誤:C#通過電子郵件
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. at line SMTP.Send(PassRecMail);
我已經打開了谷歌少保,然後還我收到此錯誤。 我該如何解決它?
有https://stackoverflow.com/questions/17227532/gmail-530-5-5-1-authentication-required-learn-more-at和https://productforums.google的讀取。 com/forum /#!topic/gmail/vtTz1ngyH8o。 – mjwills
[通過Gmail在.NET中發送電子郵件]的可能副本(https://stackoverflow.com/questions/32260/sending-email-in-net-through-gmail) – VDWWD