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

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

我知道有很多问题,但 none 似乎有适合我的答案。

我的应用程序是 ASP Classic,它 运行 所在的服务器是 Windows Server 2000(我知道它很旧),我使用的是 Office365 服务器并且我正在使用我登录邮箱时Office365提供的信息(端口587,正确的用户名和密码,正确的smtp服务器,TLS设置为true)。

我总是收到 "CDO.Message.1 error '80040213' The transport failed to connect to the server." 作为错误消息,错误所在的行是 .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

我也尝试过使用端口 25,但没有成功。如果我使用另一个根本不使用 SSL 的电子邮件服务(本地服务,而不是 Office365),我没有问题(我注释掉 usessl 并将端口更改为 25)。此外,如果我尝试使用我在 ASP.Net 应用程序中完美地 运行 的不同电子邮件服务,我会遇到同样的问题,该其他电子邮件服务使用端口 25 和 SSL,而不是 Office365 服务。

我以前遇到过这个问题。基本上,您没有通过身份验证来使用服务器上的邮件传输。

您的 SMTP 服务器不允许发送出站邮件(例如停止邮件中继),您的用户名和密码不正确,或者您使用的端口需要更高的安全级别才能发送邮件。在后面的例子中,可能是 Office365 需要 SSL 身份验证...也许值得一看。

如果一切都失败了,您可以尝试使用第 3 方提供商。我们在他们 4.35 英镑的包裹上使用 SendInBlue。您最多可以通过他们的系统发送 40,000 封电子邮件。我们发现将邮件发送给第三方完全消除了服务器设置停止邮件传输功能的问题。我们现在将其用于经典 ASP 和 PHP 站点。

希望对您有所帮助。

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

我终于能够通过将应用程序移动到 Windows Server 2012 计算机来实现它。我不得不跳过几个循环,这些循环伴随着在服务器之间移动旧的东西,但我能够让它工作。

我只能使用端口 25,587 不工作。请记住,我在原始服务器上尝试了端口 25,但在那里也不起作用。