CDO.Message - "Transport failed to connect to the server."

I am working on a classic ASP and Vbscript site that uses CDO.Message to send email to a function. I'm having problems with this function and I get an error,

CDO.Message.1 error '80040213'

The transport failed to connect to the server.

I believe this is due to the SMTP authentication settings and the shared host we are working on. I am looking for help by debugging the problem further.

Here is the main code snippet from the function,

Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields

' Set config fields we care about
With Fields
 .Item(cdoSendUsingMethod)       = cdoSendUsingPort
 .Item(cdoSMTPServer)            = "mail.<website>.com"

 '.Item(cdoSMTPServerPort)        = 25
 '.Item(cdoSMTPConnectionTimeout) = 10
 '.Item(cdoSMTPAuthenticate)      = cdoBasic
 '.Item(cdoSendUserName)          = "support"
 '.Item(cdoSendPassword)          = "password"

 .Update
End With

Set objMessage = Server.CreateObject("CDO.Message")

Set objMessage.Configuration = objConfig

With objMessage
 .To       = lEmailTo                   '"Display Name <email_address>"
 .From     = lEmailFrom                 '"Display Name <email_address>"
 .Subject  = lSubject
 .TextBody = lMessage
 .Send
End With

At first, I thought it might have been with comments 9-13 in the above snippet, but it looks like the previous developer specifically commented on them and that the email function was still working at some point in time. Uncommenting these lines still does not resolve the error.

- -, ? - , CDO.Configuration SMTP ? ?

+3
2

CDO, typelib asp. , typelib <%% > . typelib , , .

typelib .

, . , Godaddy. , /, .

<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows 2000 Type Library" -->
<%
Sub SendEmail()
Set cdoConfig = CreateObject("CDO.Configuration")

if lcase(Request.ServerVariables("SERVER_NAME")) = "dev" then
        With cdoConfig.Fields
                .Item(cdoSendUsingMethod) = cdoSendUsingPort
                .Item(cdoSMTPServer) = "xxx.<devmailservername>.xxx"
                .Item(cdoSMTPAuthenticate) = 1
                .Item(cdoSendUsername) = "xxxxxxxx@yyyyyyyyy.com"
                .Item(cdoSendPassword) = "<passwordgoeshere>"
                .Update
        End With
else
        With cdoConfig.Fields
                .Item(cdoSendUsingMethod) = cdoSendUsingPort
                .Item(cdoSMTPServer) = "xxx.<productionmailservername>.xxx"
                .Update
        End With
end if

Set cdoMessage = CreateObject("CDO.Message")

With cdoMessage
    Set .Configuration = cdoConfig
    .From = "xxxxxxx@yyyyyyyy.com"
    .To = "yyyyyyyy@zzzzzzzzz.com"
    .Subject = "Sample CDO Message"
    .htmlbody = "<html><body>Sample <b>CDO</b> message.</body></html>"
    .TextBody = "Sample CDO Message."
    .Send
End With

Set cdoMessage = Nothing
Set cdoConfig = Nothing

End Sub % > >

+1

cdoSMTPServer localhost, !

-1

Source: https://habr.com/ru/post/1724201/


All Articles