Update. Port 465 was being blocked at the corporate firewall. I have had it unblocked and now the Chilkat test works with 465 and SSL same as it did with port 587.
SMTPSecureSocket on the other hand still fails so the problem still exists. It is now definitly neither a port issue or a DNS issue. Tomorrow I will try 2019R1.1 just in case there is something about 2.1 that is the issue.
Chilkat plugin works
SMTPSecureSocket 2019R2.1 fails
I’m open to other ideas to try with SMTPSecureSocket. The Chilkat success indicates that there is something messing up in the SMTPSecureSocket authentication since regardless whether I use port 587 or 465 I get the Error “535 Authentication failed: The provided authorization grant is invalid, expired, or revoked”
// Create EmailMessage
Dim mail As New EmailMessage
mail.FromAddress = “email@example.com”
mail.Subject = SubjectField.Text
mail.BodyPlainText = MessageArea.Text
// Send it
Using a different service, I needed to remove the SSLEnabled property from my setup code. My mailsocket code looks line this in a web application running on Windows:
Self.MailSocket.Address = MailSvr // SMTP email server
Self.MailSocket.Port = MailPort // SMTP port (currently 587, the code provides for a possibility that other providers will use different ports)
Self.MailSocket.SSLConnectionType = SMTPSecureSocket.SSLConnectionTypes.TLSv1
Self.MailSocket.SMTPConnectionMode = SMTPSecureSocket.ModeSSLTLS
Self.MailSocket.Username = MailZ1 // SMTP user
Self.MailSocket.Password = MailZ2 // SMTP pw
The above code was succesfully used with two different mail providers. (not Sendgrid) It may not be applicable to Sendgrid because their requirements may be different.
Louis, I think the problem may be specific to both Windows and SendGrid together.
I have now also successfully tested the MBS CURL plugin to send on port 465 and SSL.
If I can’t get SMTPSecureSocket to successfully authenticate with SendGrid then the MBS plugin is a viable option for me. That is a plugin I own and renew annually. I just find it incredibly odd that two 3rd party solutions have no issues with SendGrid authentication and the built in Xojo class SMTPSecureSocket doesn’t work, (on Windows for me at least since Beatrix seems to not have an issue on MacOS).
I’m prepared to move on since I have a workable solution if nobody else is having problems with SMTPSecureSocket or can’t duplicate my issue.
In my previous post I was emphasising that in my tests Ports 465 and 587 need different connectionMode:
if SMTPSock.port = 587 then
SMTPsock.SMTPConnectionMode = 0//ModeSTARTTLS
SMTPsock.SMTPConnectionMode = 1//ModeSSLTLS
Same here, and I believe that applies to most developers. I gave up on the build-in sockets a long time ago and I am only using the plugins, as MBS Curl is just working. And for more complex interfaces you need them anyways. Tip for the future if you are running into suspicious firewall issues and your administrator is not available. You can test yourself by using the telnet command from an admin console: