Couldn't send message to SMTP server. Transport Error 0x80040217

0

I get this error when sending a mail through asp using gmail, I already used ports 465, 587 and 25 with same results

Dim mail dim email2 as string dim urlms as string

Dim mail 
dim email2 as string
dim urlms as string
				

mail = CreateObject("CDO.Message") 			
urlms = "http://schemas.microsoft.com/cdo/configuration/"	
mail.Configuration.Fields.Item(urlms  & "sendusing") = 2 'enviar usando port
mail.Configuration.Fields.Item(urlms  & "smtpserver") = "smtp.gmail.com"
mail.Configuration.Fields.Item(urlms  & "smtpserverport") = 465
mail.Configuration.Fields.Item(urlms  & "smtpusessl") = True
mail.Configuration.Fields.Item(urlms  & "smtpconnectiontimeout") = 60
mail.Configuration.Fields.Item(urlms + "smtpauthenticate") = 1
mail.Configuration.Fields.Item(urlms + "sendusername") = "" 'login
mail.Configuration.Fields.Item(urlms + "sendpassword") = "" 'password

mail.Configuration.Fields.Update

mail.Send

email
vbscript
asp-classic
cdo.message
asked on Stack Overflow Feb 6, 2015 by Franchojavilondo • edited Feb 10, 2015 by Franchojavilondo

4 Answers

1

If you are using 2-Step authentication in Google Account then you need to change settings either opt to "Enable Less Secure Apps" or generate app passwords that will be 16 chars and you need to use this in your code instead of your actual gmail password. https://www.google.com/settings/security/lesssecureapps

answered on Stack Overflow Sep 4, 2016 by Pranesh
0
//
// MessageId: CDO_E_LOGON_FAILURE
//
// MessageText:
//
// The transport was unable to log on to the server.
//
#define CDO_E_LOGON_FAILURE              0x80040217L

Also why are you using plus to concatinate the three config items.

Your code Dims everything twice. And it dims things as strings.

You are creating objects without using Set.

I doubt your code runs to generate an error.

answered on Stack Overflow Feb 6, 2015 by user4532213
0

It worked like a charm for my own mail server, but It fails with Gmail I don't know why....

Anyway, I tried also without the plus to concatinate and didnt work either, finally I used this:

Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message") 
     
'This section provides the configuration information for the remote SMTP server.
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.yoursite.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 ' or 587
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
     
' Google apps mail servers require outgoing authentication. Use a valid email address and password registered with Google Apps.
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="somemail@yourserver.com" 'your Google apps mailbox address
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword" 'Google apps password for that mailbox
     
ObjSendMail.Configuration.Fields.Update
     
ObjSendMail.To = "someone@someone.net"
ObjSendMail.Subject = "this is the subject"
ObjSendMail.From = "someone@someone.net"
     
' we are sending a text email.. simply switch the comments around to send an html email instead
'ObjSendMail.HTMLBody = "this is the body"
ObjSendMail.TextBody = "this is the body"
     
ObjSendMail.Send
     
Set ObjSendMail = Nothing 

http://somee.com/DOKA/DoHelpTopics.aspx?docode=false&thnid=102

And worked like a charm for my server but it didn't work for gmail.

answered on Stack Overflow Feb 9, 2015 by Franchojavilondo
0

Note: The message says LOGON ERROR. Make sure name and password is correct.

Set emailObj      = CreateObject("CDO.Message")
emailObj.From     = "dc@gail.com"

emailObj.To       = "dc@gail.com"

emailObj.Subject  = "Test CDO"
emailObj.TextBody = "Test CDO"

Set emailConfig = emailObj.Configuration
msgbox emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") 
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing")    = 2  
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1  
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl")      = true 
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername")    = "YourUserName"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword")    = "Password1"
emailConfig.Fields.Update

emailObj.Send

If err.number = 0 then Msgbox "Done"
answered on Stack Overflow Feb 9, 2015 by user4532213

User contributions licensed under CC BY-SA 3.0