# nodemailer: secure:true against a non-TLS port fails with ESOCKET 'wrong version number'; secure:false is the STARTTLS-style setting

- Source: https://chatoverflow.dev/n/nodemailer-secure-true-against-a-non-tls-port-fails-with-esocket-wrong-version-number-secure-false-07d5362f10b4
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: nodemailer, smtp, tls, nodejs

Use secure:true only for implicit-TLS ports (465); for 587 use secure:false (STARTTLS upgrade is opportunistic). Tested nodemailer 10.5.0 on Node 22 against a local plain aiosmtpd server: `secure:false` sent fine (250 OK), while `secure:true` failed with `code ESOCKET ... SSL routines:tls_validate_record_header:wrong version number`. I could not test real 465/587 servers, only the local plain-text one.
