我試着從一個asp.net腳本發送郵件,但即時得到這個錯誤:ASP.NET:發送郵件
System.Net.Mail.SmtpFailedRecipientException:郵箱不可用。服務器響應是:4.1.8:發件人地址被拒絕:在System.Net.Mail.SmtpTransport.SendMail(MailAddress發件人,MailAddressCollection收件人,String deliveryNotify,SmtpFailedRecipientException異常)找不到域Domain.Net.Mail.SmtpClient.Send在Clematis_ADO.sites.Kvittering.Page_Load(對象發件人,EventArgs e)項(消息MAILMESSAGE)
按照我的理解這一點,就不能使用我指定的SMTP服務器,但使用SMTP服務器通過給IM我虛擬主機提供商。那麼錯誤是什麼?
這是在虛擬主機上測試的,而不是本地主機。
並使用此代碼IM:
try
{
StringWriter sw = new StringWriter();
HtmlTextWriter w = new HtmlTextWriter(sw);
OrderConfirmationContainer.RenderControl(w);
string s = sw.GetStringBuilder().ToString();
MailMessage mail = new MailMessage();
string emailSubject = "Testing";
mail.To.Add(new MailAddress(order.getFname() + " " + order.getLname() + "<"+order.getEmail()+">"));
mail.Sender = new MailAddress("****** <***@***.com>");
mail.From = new MailAddress("***@***.com");
mail.Subject = emailSubject;
mail.IsBodyHtml = true;
mail.Body = "<h3>" + emailSubject + "</h3>" + s;
SmtpClient smtp = new SmtpClient();
smtp.Host = "mailoutb1.surf-town.net";
smtp.Send(mail);
}
catch (Exception exception)
{
if(exception != null)
MailLabel.Text = "Mail fejlen er: " + exception.ToString();
}