本文介绍了SMTP通过SmtpClinet(SmarterEmail服务器)发送邮件失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经配置并运行SmarterEmail服务器25端口上运行SMTP服务,配置的电子邮件帐户。

I have configured and running SmarterEmail server, running SMTP service for 25 port, configured email account.

我创建了简单的.NET应用程序通过我的电子邮件服务器发送电子邮件,这是非常简单的:

I've created simple .NET application to send email by my Email server, it is really simple:

        public void SendEmail(EmailMessage message, string username, string password, string host, int port, bool enableSsl)
    {
        MailMessage mm = new MailMessage(message.From, message.To, message.Subject, message.Message);
        NetworkCredential credentials = new NetworkCredential(username, password);

        SmtpClient sc = new SmtpClient(host, 25);
        sc.DeliveryMethod = SmtpDeliveryMethod.Network;
        sc.UseDefaultCredentials = false;
        sc.EnableSsl = enableSsl;
        sc.Credentials = credentials;

        sc.Send(mm);
    }

此应用程序失败,异常:

This application failed with exception:

未处理的异常:System.Net.Mail.SmtpException:失败发送邮件。 --->取值  ystem.Net.WebException:无法连接到远程服务器---> System.Net.S  ockets.SocketException:A连接尝试失败,因为连接的方  没有了一段时间,或已建立的连接FAILE后没有正确答复  ð,因为连接主机未能响应173.248.182.102:25     在System.Net.Sockets.Socket.DoConnect(端点endPointSnapshot,SocketAddre  SS为SocketAddress)     在System.Net.ServicePoint.ConnectSocketInternal(布尔connectFailure,袜子  等S4,S6插座,插座及放大器;插座,ip地址和放大器;地址,ConnectSocketState状态,  IAsyncResult的asyncResult,的Int32超时,异常和放大器;例外)     ---内部异常堆栈跟踪的结尾---     在System.Net.ServicePoint.GetConnection(PooledStream PooledStream,对象流  仪,布尔异步,ip地址和放大器;地址,插座及放大器; abortSocket,插座及放大器; abortSocket  6,的Int32超时)     在System.Net.PooledStream.Activate(对象owningObject,布尔异步,的Int32   超时,GeneralAsyncDelegate的AsyncCallback)     在System.Net.PooledStream.Activate(对象owningObject,GeneralAsyncDelegate   的AsyncCallback)     在System.Net.ConnectionPool.GetConnection(对象owningObject,GeneralAsyncD  elegate的AsyncCallback,的Int32 creationTimeout)     在System.Net.Mail.SmtpConnection.GetConnection(的ServicePoint服务点)     在System.Net.Mail.SmtpTransport.GetConnection(的ServicePoint服务点)     在System.Net.Mail.SmtpClient.GetConnection()     在System.Net.Mail.SmtpClient.Send(MailMessage消息)     ---内部异常堆栈跟踪的结尾---     在System.Net.Mail.SmtpClient.Send(MailMessage消息)     在SendMail.MailService.SendEmail(EmailMessage消息,字符串username,S饰  NG密码,串主机,端口的Int32,布尔enableSsl)在D:\开发\幻灯  CTS \实验\的SendMail \的SendMail \的Program.cs:行36     在SendMail.Program.Main(字串[] args)在D:\开发\项目\实验  小号\的SendMail \的SendMail \的Program.cs:行52

邮件服务器:mail.trackyt.net,端口= 25,SSL = FALSE。它不会从我的(本地)机的工作。

Mail server: mail.trackyt.net, port = 25, SSL = false. It does not work from my (local) machine.

在同一时间,如果我SmarterEmail(远程)运行该应用程序复制到机器,它成功的作品!

In the same time, if I copy this application to machine were SmarterEmail (remote) is running, it successfully works!

我认为这阻止防火墙,启用25远程机器 - 同样的结果。禁用防火墙,在本地和远程计算机 - 同样的结果

I thought it blocked by Firewall, enabled 25 on remote machine - same result.Disabled Firewall, both locally and remote machine - same result.

其它诊断:

运行SMTP通过 http://pingability.com/smtptest.jsp 测试:

Run SMTP test by http://pingability.com/smtptest.jsp:

EHLO pingability.com  250 MAST-WIN2K8R2-STD你好[207.210.209.134]  250-SIZE 31457280  250-AUTH LOGIN CRAM-MD5  250 OK  DEBUG SMTP:找到扩展大小,ARG31457280  DEBUG SMTP:找到扩展名AUTH,ARGLOGIN CRAM-MD5  DEBUG SMTP:找到扩展名OK,ARG  DEBUG SMTP:尝试进行身份验证  DEBUG SMTP:检查机制:LOGIN PLAIN DIGEST-MD5 NTLM  AUTH LOGIN  334 VXNlcm5hbWU6  c3VwcG9ydA ==  334 UGFzc3dvcmQ6  c3VwcG9ydDEyMw ==  235认证成功

它说,SMTP就可以了。

It says that SMTP is OK.

这是我的机器上远程登录:

Telnet from my machine:

微软远程登录> 0 mail.trackyt.net 25  连接到mail.trackyt.net ......无法打开连接到主机,端口  25:连接失败

从SmarterMail机相同的telnet就可以了。

Same telnet from SmarterMail machine is OK.

任何想法?

推荐答案

您从家里这样做呢?许多互联网服务供应商阻止传出端口25。

Are you doing this from home? A lot of ISPs block outgoing port 25.

在smartermail您可以添加SMTP侦听另一个端口。试着增加一为587,看看你是否可以连接到它(假设你有管理员权限才能做到这一点)。

In smartermail you can add a SMTP listener for another port. Try adding one for 587, and see if you can connect to it (assuming you have admin rights to do this).

- 戴夫

这篇关于SMTP通过SmtpClinet(SmarterEmail服务器)发送邮件失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 10:56