CDO.Message.1 error '80040213' with Google Address

user3299572 picture user3299572 · Feb 12, 2014 · Viewed 10.3k times · Source

Been having an issue trying to move our ASP page CDO over to gmail. It's about to drive me crazy. I've done some exhaustive searching and I think my code is right but I still get the dreaded: CDO.Message.1 error '80040213' The transport failed to connect to the server. on oMail.Send. Any thoughts would be much appreciated. I'm beginning to think it may be a server firewall issue.

Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2
Const cdoAnonymous = 0 
Const cdoBasic = 1 
Const cdoNTLM = 2 
Set oMail = CreateObject("CDO.Message") 

oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic 
oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "[email protected]"
oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
oMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

oMail.From = "[email protected]"
oMail.To = "[email protected]"
oMail.Bcc = ""
'oMail.To = ""
oMail.Subject = ""

oMail.HTMLBody = "<font size='2' face='Verdana, Arial, Helvetica, sans-serif'>"

oMail.HTMLBody = oMail.HTMLBody + "Name: <b>"& request.form("Name")&"</b><br>"
oMail.HTMLBody = oMail.HTMLBody + "Phone: <b>"& request.form("Phone")&"</b><br>"
oMail.HTMLBody = oMail.HTMLBody + "Email: <b>"& request.form("Email")&"</b><br>"
oMail.HTMLBody = oMail.HTMLBody + "Best Time to Call: <b>"& request.form("BestTime")&"</b><br>"
oMail.HTMLBody = oMail.HTMLBody + "Question/Comment: <b>"& request.form("Comment")&"</b><br>"

oMail.HTMLBody = oMail.HTMLBody + "</font>"
oMail.Configuration.Fields.Update

oMail.Send 

Set oMail = Nothing 
Set oMailConfig = Nothing 

Any thoughts or suggestions would be much appreciated. I've tried all the Google smtp ports 25,465, and 567. What am I missing?

Answer

user692942 picture user692942 · Feb 12, 2014

Straight from Google's own instructions;

Standard configuration instructions:

Incoming Mail (POP3) Server - requires SSL: pop.gmail.com
Use SSL: Yes
Port: 995
Outgoing Mail (SMTP) Server - requires TLS or SSL: smtp.gmail.com

Use Authentication: Yes
Port for TLS/STARTTLS: 587
Port for SSL: 465

Server timeouts Greater than 1 minute, we recommend 5
Full Name or Display Name: [your name]
Account Name or User Name: your full email address (including @gmail.com or @your_domain.com)
Email Address: your email address ([email protected] or username@your_domain.com)
Password: your Gmail password

I would also check your server has dns resolution to smtp.gmail.com and check your firewall which maybe blocking port 465, as a test try connecting without SSL to see if you can connect on 25 (see this article - Unable to send emails using gmail smtp server

Suggestion for google:

If you're having trouble sending mail but you've confirmed that encryption is active for SMTP in your mail client, try to configure your SMTP server on a different port (465 or 587).