1

For at least 10 years until recently, I've been successfully sending emails through SMTP, by using a simple VBScript with CDO.Message.

Set emailObj      = CreateObject("CDO.Message")
emailObj.From     = "myemail@hotmail.com>"
emailObj.To       = "myemail@hotmail.com"
emailObj.Subject  = "Test Email"
emailObj.TextBody = "This is a SMTP test email."

Set emailConfig = emailObj.Configuration
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp-mail.outlook.com"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
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") = 1
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "myemail@hotmail.com"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword"
emailConfig.Fields.Update
emailObj.Send

However with a new test, I notice that no SMTP of widely used email providers works anymore (Yahoo, GMail, Hotmail, Mail.com, Yandex).

For all of them I get the error message:

The transport failed to connect to the server

To be sure it wasn't a problem from my end, I tested from many computers, countries and accounts. I've been testing with the officially provided SMTP details and ports 25, 465, 587. No luck with any of them.

The code still works successfully with the SMTP of my own company and our webhosting SMTP.

We distribute the software to our customers, and we don't want them to be dependent on our own SMTP to relay their mail. They should be able to easily setup their personal email accounts on our software. It used to be as easy as checking their own email provider website and entering the provided SMTP details. However, nowadays such a trivial tasks seems to have become impossible.

Am I missing something here, is it still possible to use the SMTP of widely used email providers using Visual Basic Script and CDO?

Flavio
  • 451
  • 3
  • 26
  • What error do you receive? A lot of email providers are beefing up their security with MFA and other modern authorization methods like OAUTH2. You would need to workout what response you are getting from the SMTP server and go from there. – user692942 Mar 06 '22 at 18:29
  • @user692942 the error is: "The transport failed to connect to the server" – Flavio Mar 06 '22 at 18:32
  • That’s sounds like the configuration has changed at the email provider end, check with the provider what address and port you should be using. You could try `smtp.office365.com` as the `smtpserver` the port appears to be correct. – user692942 Mar 06 '22 at 18:38
  • @user692942 tried with `smtp.office365.com`, same error: "The transport failed to connect to the server". Tested with the settings provided by microsoft: [link](https://support.microsoft.com/en-us/office/pop-imap-and-smtp-settings-8361e398-8af4-4e97-b147-6c6c4ac95353) – Flavio Mar 06 '22 at 19:48
  • I suggest [you test it with telnet](https://stackoverflow.com/questions/39497697/asp-classic-email-80040213-the-transport-failed-to-connect-to-the-server#comment66319007_39497697) to see if it connects, if it doesn’t there is a firewall blocking it, either corporate, provider or both. The fact you get the same connection error for a bunch of different email providers tell’s me the problem is at your end, check your firewalls aren’t blocking access. – user692942 Mar 06 '22 at 22:43
  • You can't establish a TLS connection with VBScript. Learn a better language. Like anything else. – suchislife Mar 06 '22 at 22:49
  • 1
    @suchislife it’s not with VBScript, it’s with CDONTS (an extended MAPI wrapper library) to send email via SMTP / POP3 / IMAP. I know it can do it, because for years I had code that used it. The issue now is email providers authorization methods improving, but CDO is being left behind. – user692942 Mar 07 '22 at 00:04
  • @user692942 thank you for your help so far. Yes, I think what you mention is the most likely reason for these errors: Recently most email providers beefed up their security and CDO simply doesn't work anymore with most of them. If this is the case I will be forced to recode everything, for example in powershell script. Anyway, I don't agree with the decision of closing my question, it is not a duplicate! – Flavio Mar 08 '22 at 12:30
  • The error is the same, the issue now is that mail providers security has beefed up. You’ll probably have to jump through hoops to use CDONTS like creating app passwords in the provider to allow you to bypass authentication protocols. Personally though, I switched to using the SendGrid API for Classic ASP email sending a while ago and never looked back. Had to create a class in Classic ASP to facilitate it but once done worked a treat. – user692942 Mar 08 '22 at 14:00

1 Answers1

-1

Here is a list of common email providers and their methods.

I just don't see how VBScript can do this in 10 lines of code.

  • MAILTRAP - EXPLICIT TLS connection (STARTTLS)
  • GMAIL - IMPLICIT TLS connection (SSL)
  • iCLOUD - EXPLICIT TLS connection (STARTTLS)
  • OUTLOOK - EXPLICIT TLS connection (STARTTLS)
  • YAHOO.COM - EXPLICIT TLS connection (STARTTLS)
  • MAIL.COM - EXPLICIT TLS connection (STARTTLS)
  • AOL.COM - EXPLICIT TLS connection (STARTTLS)
  • COMCAST.NET - EXPLICIT TLS connection (STARTTLS)
suchislife
  • 4,251
  • 10
  • 47
  • 78
  • 1
    It is possible to send emails with TLS in VBScript, using `CDO.Message`. It used to be actually pretty simple and straighforward, I've been successfully using my code above for many years. Unfortunately, it seems that this issue is new, and related to something else. Probably, all widely used email providers are adopting extra security measures which are incompatible with CDO. – Flavio Mar 08 '22 at 12:35