2013-11-27 144 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