Node.js Nodemailer sends some weird errors in email

[Error: 8676:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:c:\ws\deps\openssl\openssl\ssl\record\ssl3_
record.c:332:] {library: 'SSL routines'.function: 'ssl3_get_record'.reason: 'wrong version number'.code: 'ESOCKET'.command: 'CONN'
}
Copy the code
Error: Unexpected socket close at Timeout._onTimeout (c:\???????? \node_modules\nodemailer\lib\smtp-transport\index.js:189:31)
    at listOnTimeout (internal/timers.js:557:17)
    at processTimers (internal/timers.js:500:7)
Copy the code

The above two types of errors are different, but the cause of the error is in the same place, look at the code:

let transporter=nodemailer.createTransport({
    host:'smtp.163.com'.port:465.secure:true.auth: {user:'???????????????? @163.com'.pass:'?????? '}});Copy the code

There’s a line called Secure, which is important here. The first error is that I send an email through Outlook, host:’smtp-mail.outlook.com’, port: XXX, secure:true.

The second error I sent was via 163, host:’smtp.163.com’, port: XXX, secure:false.

All wrong with Secure. Outlook email secure must be false, 163 Email secure must be true.

All the others are going to be the same, so it’s best to try both kinds of secure, because if one doesn’t work it’s definitely the other. In addition, 163’s auth[‘pass’] is not the email password, but the SMTP/IMAP authorization code, one for each computer, which is different. If the email is sent from a new computer, enable SMTP/IMAP through 163 and obtain the authorization code.