SMTPsecuresocket not working

I tried the example provided in API v2 with my own email SMTP settings.

I got this error code in Error 336130315
I cannot find any reference to it.

I created a TCP socket to a window and added the super class SMTPSecureSocket in public mode.

Please post your exact code. Which OS do you have and which version of Xojo do you use?

Last version of Xojo, macOS Monterey


MailSocket.Address = Preferences.SMTPserver 
MailSocket.Port = val(Preferences.SMTPport)

MailSocket.ConnectionType = SMTPSecureSocket.TLSv12

  MailSocket.SMTPConnectionType = SMTPSecureSocket.SMTPConnectionTypes.SSLTLS

  MailSocket.SSLEnabled = True

MailSocket.Username = Preferences.SMTPlogin
MailSocket.Password = Preferences.SMTPpassword

Var mail As New EmailMessage

mail.FromAddress = Preferences.SMTPfromemail
mail.Subject = TextFieldSubject.text
mail.BodyPlainText = TextAreaMessage.Text



Found the issue. When SSLEnabled is moved to false, it’s working. Maybe because there is no certificate attached?

You may want to have a read up on the SMTP protocol and the variations of SSL/TLS implementation.

Briefly, there are two flavours of secure SMTP.

  1. Implicit. The entire SMTP conversation is encapsulated within TLS. The client connects to a server socket that only responds to TLS connection requests.
  2. Explicit. The initial SMTP greeting conversation is in plain text. The client and server negotiate TLS encryption prior to exchanging data. The client connects to a server socket that accepts plain text connections and sends the STARTTLS SMTP verb to negotiate TLS encryption.

The majority of mail servers accept client submission on port 587 using explicit TLS.

That’s “Handshake failed”. If you connect a SSL socket to a plain server, or a plain client to a SSL server, the TCP part is ok, the connection happens, but when few bytes tries to be exchanged this may occur. Also for some incompatible handshakes like a client or server not implementing some expected fallback and etc.

Xojo needs its sockets updated to the latest standards ASAP. AFAIK it does not handle TLS 1.3 yet for example.

OpenSSL had huge changes over the last 2 years, and we are set to experience problems over time using outdated protocols and bugged libs.

Is there an open Issue for this?

There was some discussions about it and Xojo is aware of it.

This one if implemented today using the current OPENSSL should get all the benefits: