3

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")    = "xx@gmail.com"
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     = "xx@gmail.com"
objMail.To       = "yy@yahoo.com"

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

objMail.Send
Set objMail = Nothing
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Wan Aideed
  • 41
  • 1
  • 6
  • check this: http://stackoverflow.com/a/32788150/1682881 – Flakes Sep 30 '15 at 09:46
  • 1
    `objConfig.Fields("http://sc...on/smtpusessl") = True` is required for TLS. – Ansgar Wiechers Sep 30 '15 at 10:54
  • Thanks share your link but still error. I change smtpusessl as true and change smtp port to 25. follow exactly same in link you give to me. Is it smtpusessl required for SSL or STP? Based on my knowledge CDO can't support for TLS? Any solution in vbscript? – Wan Aideed Sep 30 '15 at 13:11
  • Port 25 is for MTA-to-MTA communication. For MUA-to-MTA communication (mail submission) use port 587 (submission) or port 465 (smtps). – Ansgar Wiechers Oct 01 '15 at 12:21

1 Answers1

2

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.)

Brian Webster
  • 30,033
  • 48
  • 152
  • 225