邮件发送失败 [英] Failure Sending Mail

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

问题描述

我已经开发了一个Web应用程序来向用户发送电子邮件,但每次我在我的开发服务器上使用它都可以正常工作但是当我在Web服务器上部署它时,它会给出一个例外,说明如下:



i have developed an web application to send an email to the user but every time i use it on my development server it works fine but when i deploy it on the webserver it gives an exception saying the following:

Error Message thrown from server:
Exception caught in CreateTestMessage2():System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 172.16.9.99:25 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpClient.GetConnection() at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at Default3.Page_Load(Object sender, EventArgs e) in c:\Inetpub\VSDC_App\Default3.aspx.cs:line 32







我的代码如下:








and my code is as below:


public partial class Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
      
        
        string to = "abcfrom@xyzfrom.in";
        string from = "abcto@xyzto.in";
        MailMessage message = new MailMessage(from, to);
        message.Subject = "Using the new SMTP client.";
        message.Body = @"Using this new feature, you can send an e-mail message from an application very easily.";
        SmtpClient client = new SmtpClient("smtp.server.com");
        client.EnableSsl = false;   
        client.UseDefaultCredentials = true;

        try
        {
            client.Send(message);
        }
        catch (Exception ex)
        {
            Response.Write("Exception caught in CreateTestMessage2():" + ex.ToString());
        }

    }
}



有人会帮我解决问题。

感谢您提前回复/回复。


will anyone help me out what is the problem.
thank for reply/replies in advance.

推荐答案

邮件非常清楚,IP地址为172.16.9.99的计算机将不接受端口25上的SMTP请求你需要联系服务器的所有者,试着找出原因。
The message is perfectly clear, the machine at IP address 172.16.9.99 will not accept an SMTP request on port 25. You need to contact the owners of the server to try and find out why.


你好,



如果有的话可以帮助...



发送带附件的电子邮件



如果有帮助,请不要忘记投票,以便其他人可以考虑作为答案。



问候,
Hi,

See this link if could help...

Send email with attachment

Please do not forget to vote if could help so that others may consider as an answer.

Regards,


端口是否打开?防火墙权限到位了吗?

进一步确保您已在Web中配置SMTP配置.Config:

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



如果需要,请查看此Microsoft视频教程:

使用ASP.NET从网站发送电子邮件 [ ^ ]

在ASP.NET中发送电子邮件的教程 [ ^ ]


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

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