1

Using the following same VBScript/ASP files, I can only manage to send out the email on a Win7 PC. When running the same script on a Windows Server 2012 R2, with all the firewalls turned off, I was unable to send out the email. There is a McAfee virus scanner but even when I disable it, I was also unable to send the email out. I have also set the Allow less secure apps: ON on the Gmail account and I still get the error on '80040211' Please help me as I run out of ideas to troubleshoot.

Dim ObjSendMail

Set ObjSendMail = CreateObject("CDO.Message")

ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = "True"
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "****@gmail.com"
ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "*****"
ObjSendMail.Configuration.Fields.Update

ObjSendMail.Subject = "Testing Send Email"
ObjSendMail.From = "****@gmail.com"
ObjSendMail.To = "hello123@gmail.com"
ObjSendMail.HTMLBody = "Send mail successful"
ObjSendMail.Send

Set ObjSendMail = Nothing

response.Write "Email Sent Successfully"

After setting up telnet, I typed telnet smtp.gmail.com 587 and I get the following response:

Pic

Hanz Cheah
  • 761
  • 5
  • 15
  • 44
  • 1
    Your settings look fine, assuming port 465 is open. I suspect this isn't a general issue with win server 2012, but rather a specific one with your server setup. Who provides your server - it could be that they have an smtp relay of their own which you can use? – John Jul 09 '18 at 09:29
  • Possible duplicate of [https://stackoverflow.com/q/23224631](https://stackoverflow.com/q/23224631/1630171). – Ansgar Wiechers Jul 09 '18 at 10:43
  • On an unrelated note: I'd recommend changing the port from 465 (SMTPS) to 587 (Submission), b/c the former has been deprecated for quite some time now. This is unlikely to be the cause of the problem, though. Last time I checked Gmail still supported both. – Ansgar Wiechers Jul 09 '18 at 10:46
  • Did you verify that you can actually connect to smtp.gmail.com:465 from your server? – Ansgar Wiechers Jul 09 '18 at 10:49
  • @AnsgarWiechers How to actually verify to connect to smtp.gmail.com:465? – Hanz Cheah Jul 11 '18 at 02:31
  • @AnsgarWiechers I have checked with the IT personnel that is reponsible for the server and confirmed that port 465 is not blocked. Unless you have other ways, to propose? – Hanz Cheah Jul 11 '18 at 02:35
  • `telnet smtp.gmail.com 465`. If you want to verify SSL as well you need something like OpenSSL for Windows, so you could do `openssl s_client -connect smtp.gmail.com:465`. – Ansgar Wiechers Jul 11 '18 at 09:21
  • @AnsgarWiechers I tried telnet smtp.gmail.com 465 but I didn't get any response. However I change it to 587 and I get the above response. – Hanz Cheah Jul 16 '18 at 08:52
  • @AnsgarWiechers can you elaborate abit about OpenSSL? How do I check using OpenSSL? – Hanz Cheah Jul 16 '18 at 08:53
  • I already gave you the command you need to run. You need to install the Windows version of OpenSSL first, though. – Ansgar Wiechers Jul 16 '18 at 09:58
  • And if port 587 responds but port 465 doesn't Google may have removed SMTPS support from Gmail (or some firewall is just blocking access to that port). Change the port in your script to 587 then. – Ansgar Wiechers Jul 16 '18 at 10:12
  • @I changed to 587 but now I get `CDO.Message.1 error '80040213' The transport failed to connect to the server.` – Hanz Cheah Jul 17 '18 at 01:24
  • I think gmail is blocked I have changed to use the company internal smtp and port and it works now. Thanks @AnsgarWiechers – Hanz Cheah Jul 17 '18 at 02:33

2 Answers2

0

Gmail is blocked by the internal firewall. I have switched to their internal smtp and port. I have managed to send out emails.

Hanz Cheah
  • 761
  • 5
  • 15
  • 44
0

Use this code

<%

Set myMail=CreateObject("CDO.Message")
myMail.BodyPart.Charset = "UTF-8"


myMail.Subject= Your Message Subject
myMail.From= "anotheremail@anotherdomain.com"
myMail.To=Receiver Email Address
myMail.CreateMHTMLBody "Test Email Subject"


myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2

myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")= SMTP_SERVER
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25 
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername")=SMTP_Email_Username
myMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword")=Smtp_Email_Password
myMail.Configuration.Fields.Update
myMail.Send
set myMail=nothing

%>