我试着从一个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();
}