SMTPSecureSocket Problem

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.

1 Like

2019R1.1 attempt = no joy.
SIGH!

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”

[code]// Connect to SendGrid
MailSocket.SSLEnabled = True
MailSocket.SSLConnectionType = SSLSocket.SSLConnectionTypes.SSLv23
MailSocket.SMTPConnectionMode = SMTPSecureSocket.ModeSTARTTLS
MailSocket.Address = “smtp.sendgrid.net
MailSocket.Port = 465
MailSocket.Secure = true

MailSocket.Username = “username”
MailSocket.Password = “password”

// Create EmailMessage
Dim mail As New EmailMessage
mail.FromAddress = “noreply@jostens.com
mail.AddRecipient(ToField.Text)
mail.Subject = SubjectField.Text
mail.BodyPlainText = MessageArea.Text
mail.Headers.AppendHeader(“X-Mailer”,“SMTP Test”)

// Send it
MailSocket.Messages.Append(mail)
MailSocket.SendMail[/code]

Can anyone else try the code on Windows? I can send emails on Xojo >2019r2.1 fine with Crapolina.

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.

[quote]MailSocket.SMTPConnectionMode = SMTPSecureSocket.ModeSTARTTLS
MailSocket.Port = 465[/quote]

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
else//465
SMTPsock.SMTPConnectionMode = 1//ModeSSLTLS
end if

I’m having the same issues with SendGrid >_<

I ended up using MBS Curl to solve the issue. The MBS sample project “CURLS send email with SSL.xojo_binary_project” gave me everything I need to make Sendgrid work for me in Xojo.

1 Like

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:

telnet [domainname or ip] [port]

On Windows you first need to activate the telnet feature I think. On macOS you can install it via homebrew (https://hakk.dev/blog/posts/getting-telnet-on-macos-catalina/) Precious tool if you want to check your firewall(s) and / or the feedback from your admins ;-).

1 Like