我是新的ASP.Net並嘗試修復郵件問題。我的網站託管在godaddy服務器上,並在ASP.Net中開發。嘗試使用下面的腳本,但它的投擲的錯誤爲「發送郵件失敗」電子郵件不能在ASP.net上工作
MailMessage mail = new MailMessage("[email protected]", "[email protected]");
SmtpClient client = new SmtpClient();
client.Host = "myhosting.secureserver.net";
// Tried "relay-hosting.secureserver.net" -Errors-Unable to connect
// Tried "smtpout.secureserver.net" -Errors-Unable to read data from
// the transport connection: net_io_connectionclosed
client.Port = 3535; //Tried 80, 3535, 25, 465 (SSL)
client.UseDefaultCredentials = false;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = false;
client.ServicePoint.MaxIdleTime = 1;
client.Timeout = 10000;
client.Credentials = new NetworkCredential("[email protected]", "mypassword");
mail.IsBodyHtml = true;
mail.Subject = "New Job";
mail.IsBodyHtml = true;
try
{
client.Send(mail);
mail.Dispose();
Response.Redirect("thankyou.html");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
當打印異常得到了下面的前發送郵件:
System.Net.Mail.SmtpException : 郵件發送失敗。 ---> System.IO.IOException:無法從傳輸 連接讀取數據:net_io_connectionclosed。在在 系統 System.Net.Mail.SmtpReplyReaderFactory.ProcessRead(字節[]緩衝液, 的Int32偏移的Int32讀,布爾的readLine)在 System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader 呼叫者,布爾ONELINE)。 Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader 呼叫者)在System.Net.Mail.CheckCommand.Send(SmtpConnection康恩, 字符串&響應)在System.Net.Mail.MailCommand.Send(SmtpConnection 康恩,字節[]命令,MailAddress from,Boolean allowUnicode)at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients,String deliveryNotify,Boolean allowUnicode,SmtpF ailedRecipientException &除外)在 System.Net.Mail.SmtpClient.Send(消息MAILMESSAGE)---內 異常堆棧跟蹤的末尾在在 _Default System.Net.Mail.SmtpClient.Send(消息MAILMESSAGE) .SendEmail(對象發件人,EventArgs的)
查看異常消息,看起來設置對端口,EnableSsl或主機smtp服務器都是不正確的。請聯繫您的提供商以獲取正確的設置 –