SSL wrong version number on SMTP almost always means your client and the server disagree about when encryption starts. Your app began a TLS handshake immediately, but the server on that port expected plain SMTP first, then STARTTLS. The usual culprit is implicit TLS settings pointed at port 587. Match the mode to the port and it goes away.
The error message
The text comes from OpenSSL, so it looks similar in every language. Python’s smtplib:
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number
Node.js (Nodemailer and others), where the error code is ERR_SSL_WRONG_VERSION_NUMBER:
Error: error:0A00010B:SSL routines::wrong version number
OpenSSL 1.1.1 and older print ssl3_get_record:wrong version number instead. PHP, Ruby and curl show the same OpenSSL reason.
What it means
Every TLS record starts with a version field. When your client sends a TLS ClientHello to a port that speaks plain SMTP, the server answers with a text greeting such as 220 smtp.example.com ESMTP. OpenSSL reads those bytes as a TLS record header, finds a “version” that makes no sense, and stops with wrong version number. OpenSSL’s reason code for this is SSL_R_WRONG_VERSION_NUMBER.
The two SMTP encryption modes:
| Port | Mode | How it starts |
|---|---|---|
| 465 | Implicit TLS | TLS handshake first, then SMTP inside it. |
| 587 | STARTTLS | Plain SMTP, the client sends STARTTLS, then TLS starts. |
| 25 | STARTTLS (optional) | Server to server delivery; often blocked for apps. |
Why it happens
- Implicit TLS on port 587:
secure: truein Nodemailer,SMTP_SSLin Python,sslin PHPMailer or Laravel with port 587. - Implicit TLS on port 25.
- A proxy or antivirus on the network intercepting SMTP and answering in plain text.
- A server that does not offer TLS on that port at all.
The reverse mistake, plain SMTP or STARTTLS on port 465, usually shows up as a timeout or a closed connection rather than this error. See SMTP connection timed out.
How to fix it
- Pick one combination and set both sides of it.
- Nodemailer: the SMTP docs say to set
secure: truefor port 465, and for port 587 or 25 to leave itfalseand let STARTTLS upgrade the connection.nodemailer.createTransport({ host: 'smtp.mailcandor.com', port: 587, secure: false, auth: { user: 'mailcandor', pass: process.env.MAILCANDOR_KEY } }); - Python: the smtplib docs say
SMTP_SSLis for situations where SSL is required from the beginning of the connection. UseSMTP_SSLon 465, andSMTPplusstarttls()on 587:import os, smtplib with smtplib.SMTP("smtp.mailcandor.com", 587) as s: s.starttls() s.login("mailcandor", os.environ["MAILCANDOR_KEY"]) - PHPMailer:
SMTPSecure = 'ssl'(orPHPMailer::ENCRYPTION_SMTPS) with port 465,'tls'(ENCRYPTION_STARTTLS) with 587. - Laravel and other frameworks: set the encryption or scheme setting to match the port in the same way.
- Test by hand to see what the server expects:
openssl s_client -connect smtp.example.com:465 -quiet openssl s_client -starttls smtp -connect smtp.example.com:587 -quiet
Which server sent it
None. This is a client-side TLS error raised before any SMTP reply. It is the same against Gmail, Microsoft 365, Yahoo or any relay, because it depends only on how your client connects. If the server did answer with a code, such as Gmail’s 530 5.7.0 Must issue a STARTTLS command first, see STARTTLS errors.
Is it temporary?
No. It fails the same way every time until the configuration changes. Retrying is pointless; fix the port or the mode.
How Mailcandor handles it
Mailcandor’s SMTP relay accepts both modes on smtp.mailcandor.com: port 465 with TLS and port 587 with STARTTLS, username mailcandor and an API key as the password. Or skip SMTP and use the email API over HTTPS. For delivery errors after sending, the deliverability coach explains bounces in plain English, and hard bounces are suppressed automatically. Look up SMTP codes with the free bounce code lookup, or browse all error codes. More free checks are on the tools page. To make sure your own domain is authenticated, follow the SPF, DKIM and DMARC setup guide.