Send email no longer working

I’m trying to send email through a mail server from my app. I’m being told the app is the problem.

This was working before. Did some setting change?

Can y’all take a quick look at my code (stripped of nonsense) ?

var fwp as new XojoCloud.Firewallport(587, XojoCloud.FirewallPort.Direction.Outgoing)

fwp.open()

if fwp.isOpen() then

var s1 as new smtpSecureSocket

s1.address = “mail.circleconsulting.us

s1.port = 465

s1.username = “circlecalc@circleconsulting.us

s1.password = " . . . . . "

s1.sslConnectionType = smtpSecureSocket.sslConnectionTypes.TLSv12

s1.sslEnabled = true

s1.connect

app.mail = new emailMessage

app.mail.fromAddress = “circlecalc@circleconsulting.us

app.mail.addRecipient(app.payerEmail)

app.mail.addRecipient(“jvscanlan@circleconsulting.us”)

app.mail.subject = "CircleCalc”

app.mail.bodyHTML = message

'app.mail.headers.addHeader(“x-app.mailer”, “smtp test”)

app.writeToLog “email from button created”, false

s1.messages.add(app.mail)

try

      s1.sendMail

catch e

      app.writeToErrorLog "oops”

end try

Why is the socket a local variable? This needs to be a property to whatever window/class you are using.

1 Like

It could be helpful if you’d share the actual error message from e instead of just “oops.” I’ve seen a few mail hosts drop support for TLS 1.2 this year but this is rare.

I believe SMTPSecureSocket also has a ServerError event you might try implementing.

usually you drop this into a window and care the events too
or as sub class would have the events easy to use.

You’re opening port 587 through the firewall, but using 465. 587 is the current standard and should be used with SMTPSecureSocket.SSLConnectionTypes.STARTTLS, which is the default.

I thought the s1.port was the port for the email server to use in sending the email from there. I don’t use imap. I use pop3, so 465 is the port on the email server.

I’m not sure what your point is about SMTPSecureSocket.SSLConnectionTypes.STARTTLS

I simplified the code where it wasn’t important for the question. In the real world it give the actual error message

I’ll try that

Okay, I’ll try that

I don’t understand “and care the events too”

but thanks

Well my point was that if we knew what the actual error message was we might be able to help solve the issue easier.

This works OK. SMTPsock is a SMTPSecureSocket dropped into the window

SMTPsock.address = trim(smtpFld.text)//“smtp.mail.yahoo.com
SMTPSock.port = 465
SMTPSock.username = userFld.text
SMTPSock.password = passFld.text
dim ss as string = myAccount
SMTPsock.ConnectionType = SSLSocket.TLSv12
SMTPsock.SMTPConnectionMode = 1
SMTPsock.secure = true

Dim mail as new EmailMessage
mail.fromAddress = userFld.text
mail.subject=subj
if isEnriched then
mail.BodyEnriched = mBody
else
mail.bodyPlainText = mBody
end if

mail.headers.appendHeader “X-Mailer”,”MyMailer”

s = ReplaceAll(t,“,”,EndOfLine)
For i = 1 to CountFields(s,Chr(13))
mail.addRecipient Trim(NthField(s,EndOfLine,i))
next

//send the mail
SMTPSock.messages.append mail
SMTPSock.SendMail

587 and 465 are both SMTP ports. IMAP and POP3 are for inbound and are irrelevant to this conversation.

465 is the older port used for explicit SSL/TLS. 587 is the current standard that allows upgrading the connection to SSL/TLS. That’s why you would set the connection type to STARTTLS, or just leave it default, same thing.

I would start with the ports. As I said, you’re opening 587 outbound, but trying to use 465, so the firewall should be blocking you.

As others have said, share the error message. Also, as others have said, there’s a good chance the socket is going out of scope before delivery. You need to store the socket in a property or as a control long enough for it to do its work.

3 Likes

Yeah, that’s what I thought. This problem just really confuses me.

This is a payPal IPN listener using the smtp from the ‘sending email from console app’ example. The firewall port and smtpSecureSocket are now just properties in APP and immediately set up upon receiving data from payPal.

Now I’ve got a button and it sends the email, but the IPN listener does not even though they have the same settings.

Button:

s1.address = “mail.circleconsulting.us
s1.port = 587
s1.username = “circlecalc@circleconsulting.us”
s1.password = “12345”

s1.sslConnectionType = smtpSecureSocket.sslConnectionTypes.TLSv12
s1.smtpConnectionType = smtpSecureSocket.smtpConnectionTypes.SSLTLS

's1.sslEnabled
s1.connect

Send email in IPN listener:

s1.address = “mail.circleconsulting.us
s1.port = 587
s1.username = “circlecalc@circleconsulting.us”
s1.password = “12345”

s1.sslConnectionType = smtpSecureSocket.sslConnectionTypes.TLSv12
s1.smtpConnectionType =smtpSecureSocket.smtpConnectionTypes.SSLTTLS

's1.sslEnabled
s1.connect

I’ve tried both sslEnabled = true and false. It donsn’t changed anything. In the IPN listener I keep getting smtp.Error: 103 (Unable to resolve address) even though it’s exactly the same. Isn’t it?

Any ideas? Thanks,

Is this Xojo Cloud? Many hosts block sending email out of the box and need approval first. I’m not sure if Xojo Cloud does this, but that’s something to check on.

I personally don’t like sending via SMTP and use third party services like MailGun or SendGrid. My service of choice is Postmark. Much less to go wrong.

1 Like

First question: If xojoCloud is getting blocked, how can it work from the button?

Can you tell me more about postMark, starting with the cost? xojoCloud is already brutally expensive. I’m now competing with someone with no expenses

There are so many services around for sending emails. Check if AppSumo has a good deal. I’m now using the free plan of Maileroo.

I would recommend SendGrid only to people I hate. Bad product and terrible service. They thought that my desktop app was hacked because the desktop app was using different IPs for sending emails.

1 Like

Ditto on SendGrid.

Postmark costs me $12 per month. It’s for transactional email only - no marketing. Which sounds fine in your case. They are quite strict about this, which is how they keep their IP addresses clean and off blacklists. That issue is why I never recommend SendGrid.

Email delivery is very hard. There’s a possibility the issue is not between Xojo and your SMTP server, but in the delivery process itself. There’s so much spam that having proper SPF, DKIM, and DMARC records is essential for reliable delivery.

I get that I’m leading you in a lot of different directions, but there are LOTS of things to do wrong.

1 Like

Just to add to the body of recommendations:

  • SendGrid is a no-go. Everything goes to spam. Just avoid it.
  • Maileroo I’ve been testing. Seems to work well, though I still get reports that some services send the mails to spam despite SPF and DKIM being setup properly.
  • Failback to a SMTP account on a mail server I control is flawless, but I wouldn’t recommend using that full-time.
2 Likes

I’ve been using ZeptoMail. Really easy API and I pay $2.50 every 6 months for 10k mails.

2 Likes