![](/img/trans.png)
[英]Send email using asp.net shows this error:The SMTP server requires a secure connection or the client was not authenticated
[英]The SMTP server requires a secure connection when i try to send an email
大家好,我創建了一個郵件類來發送電子郵件。
public void SendEmail(string subject, string messageBody, string toAddress)
{
MailMessage mail = new MailMessage();
mail.To.Add(toAddress);
//mail.To.Add("amit_jain_online@yahoo.com");
mail.From = new MailAddress("noreply3ncra@gmail.com");
mail.Subject = subject;
string Body = messageBody;
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.UseDefaultCredentials = false;
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential
("noreply3ncra@gmail.com", "********");
//Or your Smtp Email ID and Password
smtp.EnableSsl = true;
smtp.Send(mail);
}
但是我得到了這個錯誤:
SMTP服務器需要安全連接,或者客戶端未通過身份驗證。 服務器響應為:5.5.1需要身份驗證。
所以,我必須登錄到Gmail和輸入圖形驗證碼並在此之后的每一件事將是OK。
我該怎么辦?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.