Send email via SMTP (Google) working in debug but not a deployed web app

I deployed my app to Xojo Cloud to find out that it was not sending the emails. Everything was being sent fine when debugging. Am using Google to send emails as this is the service I’ve been using in my desktop apps. Any thoughts on what is wrong here?

I am open to trying SendGrid, but I am having a hard time figuring how to set it up. I’ve used this many years ago, but things seem to have changed, or I simply do not remember what I did. If there are any SendGrid users who would like to explain, I would be most appreciative

In SendGrid, I chose SMTP Relay (not the Web API) option, gave the key a name, and generated the key. In my app’s username, I tried several things. On the SG key page, it says to use “apikey” as the username, and the password is the password generated. This did not work. Also tried the name I gave the API key, but also did not work

My code for sending is below. Again, this worked in debug but not in the deployed app and only with gmail

MailSocket.Address = "smtp.gmail.com"  'swapped this for "smtp.sendgrid.net" when trying to test SG
MailSocket.Port = 465
MailSocket.ConnectionType = SMTPSecureSocket.TLSv1

MailSocket.SMTPConnectionMode = SMTPSecureSocket.ModeSSLTLS
MailSocket.Secure = True
MailSocket.UserName = app.kMailUN
MailSocket.Password = app.kMailPW

Xojo Cloud keeps everything locked down pretty much. You may have to open the smtp port before you can use it.

Thanks Tim, but I don’t understand how you would open the smtp port before using it. Can you explain? Do you just mean to call this earlier in the block of code?

I guess Tim is talking about the Xojo Cloud Firewall:
https://documentation.xojo.com/topics/xojo_cloud/xojo_cloud_details.html#firewall

Eureka! Thanks so much to you both!

1 Like