我之前完成了此操作,沒有任何問題,但現在我不知道什麼是錯誤的。我有一個網頁,上面有一個電子郵件按鈕,我想用它將一些數據發送到電子郵件地址。嘗試通過SMTP從ASP.NET發送電子郵件時的權限問題頁面
我問我們的網絡託管公司的服務器的詳細信息,我得到的迴應是:
"You can use the following details for mail.
Incoming mail server: mail.ourSite.com Outgoing mail server: mail.ourSite.com
Username and password are the email address and password associated with the email address.
"
我不知道,最後一行,但我創建的虛擬主機控制面板新的電子郵件地址。
我使用的代碼是:
// instantiate a new mail definition and load an html
// template into a string which I replace values in
// then the rest of the code below
md.Subject = String.Format("{0} {1} {2}", emailSubject, firstName, lastName);
MailMessage msg = md.CreateMailMessage(emailAddress, replacements, emailBody, new Control());
md.IsBodyHtml = true;
SmtpClient sc = new SmtpClient(emailServer);
sc.Credentials = new NetworkCredential(emailUsername, emailPassword);
try
{
sc.Send(msg);
}
emailserver的 - mail.ourSite.com(在這個崗位虛值) emailUsername - 的密碼 - 我在控制面板 emailPassword創建的電子郵件地址電子郵件以上
我的錯誤是,當我發送電子郵件至其他領域比我們自己,我得到
"Bad sequence of commands. The server response was: This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server."
當我通過電子郵件發送到我們的主機內的地址,然後它工作正常。
支持不是很支持,所以我在這裏問你可能會認爲問題可能是什麼?我覺得奇怪的是,我使用密碼來創建我創建的電子郵件地址,是否應該這樣做?
也許你正在使用錯誤的電子郵件地址和密碼。 。 – 2011-05-04 13:13:04