I have used Sendgrid as my SMTP server for many years in my desktop app. I used a username/password combination.
Recently, Sendgrid required us to all change to its API version. I simply can’t make it work using SMTPSecureSocket.
emailSender is set up as a SMTPSecureSocket property of the app in the IDE.
Here is my code for app.Open event:
emailSender = new SMTPSecureSocket
emailSender.address = "smtp.sendgrid.net"
emailSender.port = 465
EemailSender.username = "apikey"
emailSender.password = "SG.myObfuscatedAPIcode"
emailSender.SSLEnabled = True
emailSender.ConnectionType = SMTPSecureSocket.TLSv1
emailSender.SMTPConnectionMode = SMTPSecureSocket.ModeSSLTLS
And the code when I send the email:
Dim e as new EmailMessage
e.subject= textfield5.text
e.bodyHTML = textfield7.text
e.addrecipient("recipient@email.com")
e.FromAddress = "sender@email.com"
app.emailSender.messages.addrow e
app.emailSender.sendMail
Pretty standard stuff, I would have thought.
Using the same Sendgrid API credentials, I can send emails using MBSCurl plugin, but not using SMTPSecureSocket.
I have also tried ports 25 and 587. I have checked that I don’t have firewalls active. I have made sure the API has “Send email” permissions.
Am I doing something wrong, or is SMTPSecureSocket a bit hit-and-miss?