我使用的.NET版本3.5發送郵件,雖然我的web應用程序smtp.send方法拋出異常
我得到以下錯誤:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated
可能是什麼造成的?
我使用的.NET版本3.5發送郵件,雖然我的web應用程序smtp.send方法拋出異常
我得到以下錯誤:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated
可能是什麼造成的?
來源從這裏http://www.systemnetmail.com/faq/4.2.aspx
//create the mail message
MailMessage mail = new MailMessage();
//set the addresses
mail.From = new MailAddress("[email protected]");
mail.To.Add("[email protected]");
//set the content
mail.Subject = "This is an email";
mail.Body = "this is the body content of the email.";
//send the message
SmtpClient smtp = new SmtpClient("127.0.0.1");
//to authenticate we set the username and password properites on the SmtpClient
smtp.Credentials = new NetworkCredential("username", "secret");
smtp.Send(mail);
編輯:此錯誤意味着什麼它寫成:SMTP服務器需要身份驗證信息(用戶名和密碼)。所以,你需要設置SmtpClient.Credentials。
嘗試:
smtpclient.EnableSsl = true;
iths現在提供此錯誤:根據驗證過程,遠程證書無效。 – kumar 2011-05-20 11:10:55
@kumar檢查了這[黑客](http://stackoverflow.com/questions/777607/the-remote-certificate-is-invalid-according-to-the-validation-procedure-plea) – V4Vendetta 2011-05-20 11:36:48
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.1 Client was not authenticated
,所以你需要通過添加證書
smtpClient.Credentials = new NetworkCredential("username", "password");
然後憑據你提供的可能無效。 – Yaur 2011-05-20 11:18:59
你有沒有考慮增加一個故事,解釋的錯誤是什麼認證? – forsvarir 2011-05-20 11:05:46
此代碼是否需要web.config中的任何更改 – kumar 2011-05-20 11:06:30
您使用交換服務器發送郵件嗎? – 2011-05-20 11:06:36