SMTP email in 2020r2 broken

Does anyone have code working to send emails with SMTP in 2020r2?

My code is no longer working in 2020r2 Windows 10.

As always: how does your code look like? What error do you get? Are you using Xojo code, CURL or Chilkat? At least try with CURL to get more information.

Have you shot yourself in the knee? I like to block myself with LittleSnitch.

1 Like

Dim smtp As New SMTPSecureSocket
smtp.Address = “mail.serverwarp.com”
smtp.Secure = True
smtp.Port = 587
smtp.ConnectionType = SSLSocket.TLSv12
smtp.Username = “noreply_resetcodes@realmakers.net”
smtp.Password = “[password]”

Dim mail As New EmailMessage
mail.FromAddress = “email@domainname.com”
mail.AddRecipient(t2email.Text)
mail.Subject = “Email Verification PIN.”
Dim tttt As String
tttt = “Your Email Verification PIN is:”+ Str(123) + “.”
mail.BodyPlainText = tttt

smtp.Messages.Append(mail)
smtp.SendMail()

Remember that SMTPSocket needs to stay in scope while it sends mail, this looks like smtp is going out of scope at the end.

Are you getting any kind of error events or codes?

I am getting no errors that pop up, not even sure as how to check for errors other than try to catch exceptions.

I am now trying the sample code at:

http://documentation.xojo.com/api/networking/smtpsecuresocket.html

You’ll notice the sample code doesn’t dim smtp as new SMTPSecureSocket. The socket instance is kept as a property on something so it stays in scope. The last time I used it, I put this all into a Module and used a property of the module to keep the sockets in scope.

1 Like

I am working on that right now.

I did notice that the online docs do not reflect SMTPConnectionMode and its 0 / 1 options.

These are all the options available for my socket.

SMTPConnectionMode became SMTPConnectionType in API 2.0, which is why you won’t find it in the online docs. I can see both in your suggestions list there :slight_smile:

1 Like

Huh. The online docs reflect the usage of a ConnectionType which is no longer offered for SMTPSecureSocket.

https://documentation.xojo.com/api/networking/smtpsecuresocket.html#smtpsecuresocket-smtpconnectiontype

Is new to 2019r2 (API 2.0) and uses the enumeration system.

https://documentation.xojo.com/api/deprecated/deprecated_class_members/smtpsecuresocket.smtpconnectionmode.html

Is API 1.0 using the old magic numbers system.

1 Like

You may want:

smtp.ConnectionType = SSLSocket.SSLv32

unless you know for certain that the other end will do TLSv12. SSLv32 is a magic one that starts at TLSv12 and will negotiate downwards if required.

2 Likes

Tried to test known good code on 2019r3.2 and then I got this:

I uninstalled, reinstalled, got the same problem. :face_with_symbols_over_mouth:

That is a different problem that has been discussed a few times.

https://forum.xojo.com/t/cannot-run-from-ide-wrong-url-2020-r1-1-r1-2/

1 Like

I fixed the issue by running with Default app being FireFox. :weary: Email code that WAS working appears to now no longer be working - 2019r3.2

And I have confirmed that the live app that has been running a few years now is no longer working. Oh, this is gonna be fun. I am going to try sending through GMail’s SMTP to see if this problem is perhaps a problem with the email server that I am using.

Are you using the latest Chrome Browser? Updated it if not.

I think I updated it last night.

Google Chrome is up to date

Version 87.0.4280.141 (Official Build) (64-bit)

Yep - I did update it last night.

I am now getting NilObjectException when sending code from a module:

ms.Address = emailServiceAddress
ms.Port = emailPort587
ms.SSLConnectionType = SSLSocket.SSLConnectionTypes.SSLv23
ms.SMTPConnectionType = SMTPSecureSocket.SMTPConnectionTypes.SSLTLS
ms.SMTPConnectionMode = 0
ms.Username = emailname
ms.Password = emailPass
ms.SSLEnabled = True

var mail as New EmailMessage
mail.FromAddress = emailname
mail.AddRecipient("amy@lltconnect.com")
mail.Subject = "test email"
mail.BodyPlainText = "testing some new code."
mail.Headers.AddHeader("X-Mailer","SMTP Test")

ms.Messages.Add(mail)

Try
  
  ms.SendMail
  
Catch e As RuntimeException
  
  MessageBox(e.Message)
  
End Try