smtp发送邮件注册中的错误 [英] error in smtp sending mail reg

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

问题描述

我使用以下代码从asp.net页面发送邮件:

I used following code to send mail from asp.net pages:

protected void Page_Load(object sender, EventArgs e)
   {
       if (!IsPostBack)
       { }
   }
   protected void Button1_Click(object sender, EventArgs e)
   {
       Response.Write(SendMail("info@letrouters.com", "info@letrouters.com", "info@letrouters.com", "Test Mail", "Test Mail Body"));
   }
    public string SendMail(string toList, string from, string ccList, string subject, string body)
   {
       MailMessage message = new MailMessage();
       SmtpClient smtpClient = new SmtpClient();
       string msg = string.Empty;
       try
       {
           MailAddress fromAddress = new MailAddress(from);
           message.From = fromAddress;
           message.To.Add(toList);
           if (ccList != null && ccList != string.Empty)
               message.CC.Add(ccList);
           message.Subject = subject;
           message.IsBodyHtml = true;
           message.Body = body;
           smtpClient.Host = "mail.letrouters.com";
           smtpClient.Port = 25;
           smtpClient.UseDefaultCredentials = true;
           smtpClient.Credentials = new System.Net.NetworkCredential("info@letrouters.com", "XXXXX");

           smtpClient.Send(message);
           msg = "Successful";
       }
       catch (Exception ex)
       {
           Response.Write(ex.Message);
       }

      return msg;
   }




我收到诸如在第(c0>)行发送邮件失败的错误

我正在尝试使用asp.net将消息发送到我的companymail ID.




I am getting error such as failure in sending mail at line (smtpClient.Send(message);)

I am trying to send message to my companymail id using asp.net.
Can any one guide me and help me to come out of this problem?

推荐答案

如果您在.NET framework 4.0中工作,并希望发送带有附件大小的邮件,可以帮助我解决这个问题吗?大于3 megabyte,则可能需要安装Microsoft .NET Framework 4 Client Profile补丁.有关详细信息和下载,请查看 [^ ] KB.



我懂了.这是要检查的东西

1.防火墙允许通过邮件服务器发送邮件.
2.网络问题.
3.邮件服务器正常工作.您可以使用Microsoft Outlook Thunderbird [ ^ ]

希望对您有帮助.
If you are working in .NET framework 4.0 and want to send a mail with an attachment size greater that 3 megabyte, then your might need to install a Microsoft .NET framework 4 Client Profile patch.For detail and download, take a look at this [^] KB.



I see. Then here are things to check

1. Firewall is allowing to send mail through the mail server.
2. Network issue.
3. The mail server is properly working.You can check this by sending mail using Microsoft Outlook or Thunderbird[^]

I hope this will help you well.


可能是由于各种原因.您需要一一看待它们.

港口开放吗?防火墙权限到位了吗?
进一步确保您已在Web.Config中配置了SMTP配置(为简便起见!),并使用了有效值:
It can be because of various reasons. You need to look at them one by one.

Is the port open? Firewall permissions in place?
Further make sure you have configured SMTP configuration in Web.Config(for ease!) and with valid values:
<system.net>
   <mailSettings>
     <smtp from="abc@somedomain.com">
       <network host="somesmtpserver" port="25" userName="name" password="pass" defaultCredentials="true" />
     </smtp>
   </mailSettings>
</system.net>


如果需要,请查看此Microsoft Video教程:
使用ASP.NET发送来自网站的电子邮件 [在ASP.NET中发送电子邮件的教程 [


If needed, have a look at this Microsoft Video tutorial:
Use ASP.NET to send Email from Website[^]
Tutorials on sending Email in ASP.NET[^]


尝试:

Try:

smtpClient.UseDefaultCredentials = false;



参见:
http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.credentials.aspx [ ^ ]



See:
http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.credentials.aspx[^]


这篇关于smtp发送邮件注册中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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