2013-11-27 225 views
0

我的网站(我将称之为mydomain.com)托管在运行Windows Server 2008 R2的专用服务器上(1 & 1)。对于防病毒保护,它具有AVG File Server Edition 2013.Windows防火墙未启用。SmtpClient无法发送电子邮件

在该服务器上,我安装了SmarterMail,并通过子域名mail.mydomain.com将其用于我的所有电子邮件。从我的网站,我发送电子邮件,它工作正常。

今天我设立了一个用Rackspace进行电子邮件托管的帐户,并试图测试它作为托管在我自己的服务器上的替代品。我正在测试一个不同的域名myotherdomain.com。我已经在Rackspace中设置了两个用户帐户,并在本地系统上设置了Outlook,以便为这个新域发送和接收电子邮件,并且在Outlook中工作正常。

但是,当我尝试从我的网站发送电子邮件时,出现错误。下面是我用在我的测试页的Page_Load中的VB.NET代码:

Dim Msg As New MailMessage("[email protected]", "[email protected]") 

With Msg 
    .Subject = "Email test" 
    .Body = "This is a test message." 
    .IsBodyHtml = True 
End With 

Dim Smtp As New SmtpClient 

With Smtp 
    .UseDefaultCredentials = False 
    .Credentials = New NetworkCredential("[email protected]", strPassword) 
    .DeliveryMethod = SmtpDeliveryMethod.Network 
    .EnableSsl = True 
    .Host = "secure.emailsrvr.com" 
    .Port = 465 
End With 

Try 
    Smtp.Send(Msg) 

    lblMessage.Text = "Success!" 

Catch SmtpEx As SmtpException 
    lblMessage.Text = "SMTP exception: " & SmtpEx.Message 
    If SmtpEx.InnerException IsNot Nothing Then lblMessage.Text &= " (InnerException: " & SmtpEx.InnerException.Message & ")" 

Catch GeneralEx As Exception 
    lblMessage.Text = "General exception: " & GeneralEx.Message 
End Try 

我可以登录到Rackspace公司的电子邮件门户[email protected]和strPassword的值。

我从试图从我的网站发送电子邮件时得到的SMTP错误消息是:发送邮件失败。 (InnerException:无法从传输连接读取数据:net_io_connectionclosed。)

在我的1 & 1控制面板中,我为myotherdomain.com的DNS设置配置了一个未在其他地方使用的IP地址,我已经为myotherdomain.com定义了该IP地址的反向映射。我还指定它使用另一台邮件服务器,并按照Rackspace的规定定义了mx0和mx1服务器名称。

有人可以请一些想法,以帮助理解为什么电子邮件不能从我的网站,当它是托管在Rackspace域名?谢谢!

回答

2

我刚刚遇到了使用Rackspace SMTP的相同问题。问题是.net SmtpClient不支持Implicit SSL,这是在该SMTP服务器的端口465上提供的。我切换到使用端口587,它工作正常。

http://blogs.msdn.com/b/webdav_101/archive/2008/06/02/system-net-mail-with-ssl-to-authenticate-against-port-465.aspx

+0

不,他们给了我准确的信息,但因为我有同样的问题,因为OP,我打电话给Rackspace公司的电子邮件技术支持,谁告诉我,他们支持在端口465上显式SSL的安全。 emailsrvr.com。我无法使用SSL组合来使用SSL。 – Tim