简体   繁体   English

ASP Classic电子邮件'80040213'传输无法连接到服务器

[英]ASP Classic Email '80040213' The transport failed to connect to the server

I know there are plenty of questions out there with this but none seem to have an answer which works for me. 我知道有很多问题,但似乎没有一个答案对我有用。

My application is ASP Classic, the server it is running on is Windows Server 2000 (very old I know), I am using an Office365 server and I'm using the information provided by the Office365 when I login to the email (Port 587, correct username and password, correct smtp server, TLS set to true). 我的应用程序是ASP Classic,它运行的服务器是Windows Server 2000(我知道很老),我使用的是Office365服务器,当我登录电子邮件时,我正在使用Office365提供的信息(Port 587,正确的用户名和密码,正确的smtp服务器,TLS设置为true)。

I always get "CDO.Message.1 error '80040213' The transport failed to connect to the server." 我总是得到“CDO.Message.1错误'80040213'传输无法连接到服务器。” as an error message, the line it errors on is the .Send command. 作为错误消息,它出错的行是.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) = "my.email@email.com"
    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 = "to.email@email.com"
    objCDOSYSMail.To = "my.email@email.com"
    objCDOSYSMail.Subject = "A subject"
    objCDOSYSMail.HTMLBody = "Some text for the body"

    'Normal level of importance
    objCDOSYSMail.Send

    set objCDOSYSMail = nothing
    set objCDOSYSCon = nothing

I have tried with port 25 without any luck as well. 我已尝试使用端口25而没有任何运气。 If I use another email service which doesn't use SSL at all (local service, not Office365) I have no issue (I comment out usessl and change the port to 25). 如果我使用另一个根本不使用SSL的电子邮件服务(本地服务,而不是Office365)我没有问题(我注释掉usessl并将端口更改为25)。 Additionally if I try to use a different email service which I have running flawlessly in an ASP.Net application I get the same issues, this other email service uses port 25 and SSL and is not an Office365 service. 此外,如果我尝试使用不同的电子邮件服务,我在ASP.Net应用程序中运行完美,我得到相同的问题,这个其他电子邮件服务使用端口25和SSL,而不是Office365服务。

I have had this issue before. 我以前遇到过这个问题。 Basically you're not being authenticated to use the mail transport on the server. 基本上,您没有通过身份验证来使用服务器上的邮件传输。

Either your SMTP server isn't allowed to send outbound mail (eg to stop mail relay), you're username and password are incorrect or the port you are using needs a higher security level to send the mail. 您的SMTP服务器不允许发送出站邮件(例如,停止邮件中继),您的用户名和密码不正确,或者您使用的端口需要更高的安全级别来发送邮件。 In the later instance it could be that Office365 requires SSL auth...maybe worth looking there. 在后一种情况下,Office365可能需要SSL身份验证......也许值得一看。

If all else fails you can try using a 3rd party provider. 如果一切都失败了,您可以尝试使用第三方提供商。 We use SendInBlue on their £4.35 package. 我们在4.35英镑的套餐中使用SendInBlue。 You're allowed to send up to 40,000 emails through their system. 您可以通过他们的系统发送最多40,000封电子邮件。 We found that sending the mail to a 3rd party totally removes issues over server settings stopping the mail transport function. 我们发现将邮件发送到第三方完全消除了停止邮件传输功能的服务器设置问题。 We use this for both Classic ASP and PHP sites now. 我们现在将它用于Classic ASP和PHP站点。

Hope that helps. 希望有所帮助。

With Office 365 and CDO you have to use port 25, even if you're using authenication. 使用Office 365和CDO,即使您使用身份验证,也必须使用端口25。 Looking at your code I think the port is the only thing to change, but here's a tried and tested configuration. 看看你的代码我认为端口是唯一要改变的东西,但这是一个久经考验的配置。

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") = "myaccount@mydomain.com"
        .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword"
        .Update
End With
objMail.Configuration = iConfg

I was finally able to get this working by moving the application to a Windows Server 2012 machine. 我终于能够通过将应用程序移动到Windows Server 2012计算机来实现这一目标。 I had to jump through a couple of loops which come with moving something that old between servers but I was able to get it working. 我不得不跳过几个循环,这些循环在服务器之间移动旧的东西,但我能够让它工作。

I was only able to use Port 25, 587 doesn't work. 我只能使用端口25,587不起作用。 Keep in mind I tried port 25 on the original server and that didn't work there either. 请记住,我在原始服务器上尝试了端口25,但也没有在那里工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM