Wan Aideed
Wan Aideed

Reputation: 41

Sending an email over TLS

I've try send email using TLS and port number is 587 with server name is smtp.gmail.com but always got error "error '8004020e'". I set SSL to false because the port 587 Authentication is TLS. Any wrong in my code?

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

Set objConfig = CreateObject("CDO.Configuration")

objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing")    = 2
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl")      = false 
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername")    = "[email protected]"
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword")    = "xx"
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

objConfig.Fields.Update

Set objMail.Configuration = objConfig

objMail.From     = "[email protected]"
objMail.To       = "[email protected]"

objMail.Subject  = "Test EMAIL"
objMail.TextBody = "Test EMAIL"
objMail.HTMLBody = "fffffffffff"

objMail.Send
Set objMail = Nothing

Upvotes: 3

Views: 6866

Answers (1)

Zoltan Bozser
Zoltan Bozser

Reputation: 21

Use port 465 instead and use ssl (smtpusessl = True) for Gmail or Amazon SES SMTP.

And also have to make sure (log in to the Gmail account mailbox, check if there are messages, that tell you about previous unsuccessful attempts) that the mailbox usage for the "old applications" are enabled... (it's a new "feature", that can be enabled on Yahoo and Google mail servers since not too long ago... Even maybe some mobile email clients will not work if this is not set.)

Upvotes: 2

Related Questions