SSL: WRONG_VERSION_NUMBER (SMTP port) Email / SMTP Origin: Network OSI layer 6 · Presentation Last updated 4 Nov 2026

SMTP: [SSL: WRONG_VERSION_NUMBER] wrong version number — SMTP over SSL on a STARTTLS port

Your client tried to start TLS immediately on a port where the server speaks plain SMTP first (or the reverse), so the handshake looks garbled.

Exact message you may see [SSL: WRONG_VERSION_NUMBER] wrong version numberssl.SSLError: [SSL: WRONG_VERSION_NUMBER]error:1408F10B:SSL routines:ssl3_get_record:wrong version numberSSL routines wrong version number SMTPpacket length too long smtp
Seen on: SMTP Python Linux

Meaning

Port 465 uses implicit TLS (SSL from the first byte); port 587 starts plain and upgrades with STARTTLS. Mixing them gives wrong version number, packet length too long or unexpected EOF. Match the connection mode to the port.

Common causes

  • SSL/TLS enabled on port 587 (should be STARTTLS)
  • STARTTLS used on port 465 (should be implicit SSL)
  • Port 25 with TLS wrapper mode
  • A proxy or antivirus intercepting SMTP
  • Server not offering TLS at all

⚡ Quick fix

  1. Port 587 → STARTTLS (secure: false in Nodemailer, SMTP() + starttls() in Python)
  2. Port 465 → implicit TLS (SMTP_SSL, secure: true)
  3. Test with openssl first

Detailed fix by platform

Linux

  1. openssl s_client -starttls smtp -connect smtp.example.com:587 (STARTTLS) vs openssl s_client -connect smtp.example.com:465 (implicit)

Code examples

Correct per port

python
import smtplib
# 587: plain connect, then upgrade
s = smtplib.SMTP("smtp.example.com", 587); s.starttls()
# 465: TLS from the start
s2 = smtplib.SMTP_SSL("smtp.example.com", 465)

How to diagnose

  1. Port — 465 or 587?
  2. Mode — SSL or STARTTLS?
  3. Proxy — AV or proxy in between?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Network. Errors that are often confused with or caused by this one (click to open):

421 4.7.0 Try again later (rate limited) — SMTP: 421 4.7.0 Our system has detected an unusual rate of unsolicited mail originating from your IP address. Mail sent from your IP address has been temporarily rate limited (Email / SMTP)421 4.7.0 Try again l…450 4.7.1 Greylisted, please try again later — SMTP: 450 4.7.1 <user@example.com>: Recipient address rejected: Greylisted, see http://postgrey.schweikert.ch/help/example.com.html (Email / SMTP)450 4.7.1 Greylisted,…451 4.3.0 Local error in processing — SMTP: 451 4.3.0 Error: queue file write error / 451 Requested action aborted: local error in processing (Email / SMTP)451 4.3.0 Local error…530 5.7.0 Authentication Required — SMTP: 530 5.7.0 Must issue a STARTTLS command first / 530 5.7.1 Authentication required (Email / SMTP)530 5.7.0 Authenticat…Nodemailer: Greeting never received — Nodemailer: Error: Greeting never received (code: 'ETIMEDOUT', command: 'CONN') (Email / SMTP)Nodemailer: Greeting …PHPMailer: SMTP connect() failed — PHPMailer: SMTP Error: Could not connect to SMTP host. Failed to connect to server (SMTP connect() failed) (Email / SMTP)PHPMailer: SMTP conne…self-signed certificate (SMTP TLS) — Nodemailer: Error: self signed certificate in certificate chain (code: 'ESOCKET') / unable to verify the first certificate (Email / SMTP)self-signed certifica…SMTPServerDisconnected: Connection unexpectedly closed — Python: smtplib.SMTPServerDisconnected: Connection unexpectedly closed (Email / SMTP)SMTPServerDisconnecte…SSL: WRON…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.