ASP.NET:发送邮件 [英] ASP.NET: Send Mail

查看:204
本文介绍了ASP.NET:发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着从一个asp.net脚本发送邮件,但即时得到这个错误:

* System.Net.Mail.SmtpFailedRecipientException:邮箱不可用。服务器响应为:4.1.8:发件人地址被拒绝:域名不System.Net.Mail.SmtpTransport.SendMail(MailAddress发件人,收件人MailAddressCollection,字符串deliveryNotify,SmtpFailedRecipientException&安培;除外)发现在System.Net.Mail.SmtpClient.Send在Clematis_ADO.sites.Kvittering.Page_Load(对象发件人,EventArgs e)项(消息MAILMESSAGE)*

据我了解这一点,就可以使用SMTP服务器通过空间商提供IM不使用我指定的SMTP服务器,但。因此,可以在错误是什么?

这是对虚拟主机提供商进行测试,不是localhost。

和使用这个code IM:

 尝试
         {
             StringWriter的SW =新的StringWriter();
             HtmlTextWriter的W =新的HtmlTextWriter(SW);
             OrderConfirmationContainer.RenderControl(重量);
             。字符串s = sw.GetStringBuilder()的ToString();             邮件MAILMESSAGE新= MAILMESSAGE();             字符串Emailsubject的=测试;             mail.To.Add(新MailAddress(order.getFname()++ order.getLname()+&下;+ order.getEmail()+>中));
             mail.Sender =新的MailAddress(******< *** @ *** COM方式>);
             mail.From =新的MailAddress(*** @ *** COM。);
             mail.Subject = Emailsubject的;
             mail.IsBodyHtml = TRUE;
             mail.Body =下; H3>中+ Emailsubject的+&下; / H3>中+ S;             SmtpClient SMTP =新SmtpClient();
             smtp.Host =mailoutb1.surf-town.net;
             smtp.Send(邮件);         }
         赶上(例外的例外)
         {
             如果(例外!= NULL)
                MailLabel.Text =邮件fejlen ER:+ exception.ToString();
         }


解决方案

你所得到的错误似乎是因为SMTP服务器实​​际上是拒绝电子邮件,因为你要发送或从域名或者是错误的或被列入黑名单。

您使用的是伪造的电子邮件地址与测试或一个真实的(请告诉我,你是不是真的试图发送电子邮件至,或从 ** ** @ .COM)?如果是真的,那么就要打电话给你的ISP,看看黑名单他们正在使用,看看你要发送的域名被列入黑名单。

Im trying to send a mail from a asp.net script, but im getting this error:

*System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: 4.1.8 : Sender address rejected: Domain not found at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception) at System.Net.Mail.SmtpClient.Send(MailMessage message) at Clematis_ADO.sites.Kvittering.Page_Load(Object sender, EventArgs e)*

As i understand this, it can't use the smtp server that i specified, but im using the smtp server giving by my webhost. So what could the error be?

This is tested on the webhost, not localhost.

And the code im using for this:

 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();
         }

解决方案

The error you are getting seems to be because the SMTP server is actually rejecting the email because the domain name you are trying to send to or from is either wrong or is blacklisted.

Are you using a fake email address to test with or a real one (please tell me you aren't really trying to send an email to or from **@**.com)? If it's real, you'll likely have to call your ISP and see what blacklist they are using and see if the domain you are trying to send to is blacklisted.

这篇关于ASP.NET:发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆