【发布时间】:2010-12-08 18:02:34
【问题描述】:
我尝试从 asp.net 脚本发送邮件,但收到此错误:
System.Net.Mail.SmtpFailedRecipientException:邮箱不可用。服务器响应为:4.1.8:发件人地址被拒绝:在 System.Net.Mail.SmtpTransport.SendMail(MailAddress 发件人,MailAddressCollection 收件人,字符串 deliveryNotify,SmtpFailedRecipientException& 异常)处找不到域 System.Net.Mail.SmtpClient.Send( MailMessage 消息)在 Clematis_ADO.sites.Kvittering.Page_Load(Object sender, EventArgs e)
据我了解,它不能使用我指定的 smtp 服务器,但我使用的是我的虚拟主机提供的 smtp 服务器。那么错误可能是什么?
这是在 webhost 上测试的,而不是 localhost。
以及我为此使用的代码:
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();
}
【问题讨论】:
标签: asp.net