2016-09-14 176 views
1

我知道這裏有很多問題,但沒有一個似乎有一個適用於我的答案。ASP經典電子郵件'80040213'運輸無法連接到服務器

我的應用程序是ASP Classic,它運行的服務器是Windows Server 2000(我很熟悉),我使用的是Office365服務器,當我登錄到電子郵件時使用Office365提供的信息(端口587,正確的用戶名和密碼,正確的SMTP服務器,TLS設置爲true)。

我總是得到「CDO.Message.1錯誤‘80040213’運輸未能連接到服務器。」作爲錯誤消息,它發生錯誤的行是.Send命令。

Const cdoSendUsingMethod   = "http://schemas.microsoft.com/cdo/configuration/sendusing" 
    Const cdoSendUsingPort    = 2 
    Const cdoSMTPServer    = "http://schemas.microsoft.com/cdo/configuration/smtpserver" 
    Const cdoSMTPServerPort   = "http://schemas.microsoft.com/cdo/configuration/smtpserverport" 
    Const cdoSMTPConnectionTimeout  = "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout" 
    Const cdoSMTPAuthenticate   = "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" 
    Const cdoBasic      = 1 
    Const cdoSendUserName    = "http://schemas.microsoft.com/cdo/configuration/sendusername" 
    Const cdoSendPassword    = "http://schemas.microsoft.com/cdo/configuration/sendpassword" 
    'Use SSL for the connection (False or True) 
    Const cdoSendTLS     = "http://schemas.microsoft.com/cdo/configuration/smtpusessl" 

    ' create CDOSYS objects 
    Set objCDOSYSMail = Server.CreateObject("CDO.Message") 
    Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration") 

    'Set our smtp server 
    objCDOSYSCon.Fields.Item(cdoSMTPServer) = "smtp.office365.com" 
    objCDOSYSCon.Fields.Item(cdoSMTPAuthenticate) = cdoBasic 
    objCDOSYSCon.Fields.Item(cdoSendUserName) = "[email protected]" 
    objCDOSYSCon.Fields.Item(cdoSendPassword) = "password" 
    'objCDOSYSCon.Fields.Item(cdoSMTPServerPort) = 587 
    objCDOSYSCon.Fields.Item(cdoSendUsingMethod) = cdoSendUsingPort 
    objCDOSYSCon.Fields.Item(cdoSendTLS) = True 
    objCDOSYSCon.Fields.Item(cdoSMTPConnectionTimeout) = 30 

    objCDOSYSCon.Fields.Update 

    'Use our new configurations for our mailer 
    Set objCDOSYSMail.Configuration = objCDOSYSCon 

    strSpecFile = Application("px683_network_downloads_specs") & strSpecFileName 

    objCDOSYSMail.From = "[email protected]" 
    objCDOSYSMail.To = "[email protected]" 
    objCDOSYSMail.Subject = "A subject" 
    objCDOSYSMail.HTMLBody = "Some text for the body" 

    'Normal level of importance 
    objCDOSYSMail.Send 

    set objCDOSYSMail = nothing 
    set objCDOSYSCon = nothing 

我試了端口25沒有任何運氣以及。如果我使用另一個根本不使用SSL的電子郵件服務(本地服務,而不是Office365),我沒有問題(我註釋掉usessl並將端口更改爲25)。此外,如果我嘗試使用ASP.Net應用程序中完美運行的其他電子郵件服務,則會遇到同樣的問題,此其他電子郵件服務使用端口25和SSL,而不是Office365服務。

+0

從'的telnet smtp.office365.com 587'命令行中鍵入如果你沒有得到一個「服務就緒」的回覆,你的互聯網服務提供商阻止端口。 – Henry

+1

我已經試過了,只是忘了提及它。我得到服務準備就緒,但自從您恢復準備就緒後,我重試並嘗試進行一些挖掘(嘗試登錄)。我進來了,但是當我進入MAIL FROM:命令的時候,我得到了2個響應,第一個是「無效地址」,這很奇怪,所以我重試了,並且我得到了「客戶端未通過身份驗證發送匿名郵件的郵件」 – Atlim

回答

0

我終於能夠通過將應用程序移動到Windows Server 2012計算機來實現這個工作。我不得不跳過兩個循環,這些循環是在服務器之間移動一些舊的東西,但我能夠實現它的工作。

我只能使用端口25,587不起作用。請記住,我嘗試了原始服務器上的端口25,但在那裏也沒有工作。

0

我以前有過這個問題。基本上你沒有被認證使用服務器上的郵件傳輸。

無論您的SMTP服務器不允許發送出站郵件(例如停止郵件中繼),你的用戶名和密碼不正確,或者您正在使用需要更高的安全級別的端口來發送郵件。在後面的例子中,它可能是Office365需要SSL認證......也許值得一看。

如果一切都失敗,您可以嘗試使用第三方提供商。我們在他們的£4.35包裝上使用SendInBlue。您可以通過他們的系統發送多達40,000封電子郵件。我們發現,將郵件發送給第三方完全可以解決停止郵件傳輸功能的服務器設置問題。我們現在將這個用於經典ASP和PHP網站。

希望有所幫助。

+0

我有正確的用戶名和密碼,因爲我可以使用microsoft在線登錄頁面登錄Office365,而且我使用的端口,SMTP服務器和TLS基於Office 365電子郵件帳戶在登錄時提供的設置信息。我們的其他電子郵件服務在非VBScript程序中工作得非常好,但其他電子郵件服務在此不起作用,所以我的下一個猜測是它必須是服務器不允許使用電子郵件,但如前所述,我可以使用非SSL服務這工作得很好。 – Atlim

0

對於Office 365和CDO,即使您使用認證,也必須使用端口25。看看你的代碼,我認爲這個端口是唯一需要改變的地方,但是這裏有一個久經考驗的配置。

Set iConfg = Server.CreateObject("CDO.Configuration") 
Set Flds = iConfg.Fields 
With Flds 
     .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
     .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.office365.com" 
     .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
     .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 
     .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 
     .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true 
     .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "[email protected]" 
     .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword" 
     .Update 
End With 
objMail.Configuration = iConfg 
+0

我在我的代碼片段後面提到了我已經嘗試了與完全相同的問題的端口25。我試過你的代碼片段,但是我收到完全相同的問題。 – Atlim

+0

就像我說的那樣,這個配置 - 顯然帶有不同的用戶名和密碼 - 對我很有用。有各種各樣的事情可以觸發「傳輸無法連接到服務器」的消息,這可能是值得與運行自己的Web服務器的人交談。這是一個可能感興趣的鏈接。 https://clicdatacoder.wordpress.com/2012/07/13/sending-smtp-mail-via-office-365-exchange-using-cdo-message-and-other-applications/ – John