What does ESOCKET error mean when I'm trying to send an email?

I'm trying to send an email using nodemailer.

In my LAN there is a SMTP server listening on port 25. If I use telnet, it works fine.

My js script is:

this.transporter.sendMail(mailOptions, function (error, info) { if (error) { console.log(JSON.stringify(error)); return callback(error, null); } console.log(JSON.stringify(info)); return callback(null, true);
});

It only prints: {"code":"ESOCKET","command":"CONN"}. What does it mean?

Thanks in advance

1 Answer

Per (and it's follow-ups):

same problem here. resolved it by using IP address as host, see

For us it seems to be related to throttling as circa 140 messages go through in a batch while the remainder get this error (and all are being sent to the same email address, so no issue re: bad email addresses). Changing to an IP didn't solve the issue (maybe because the SMTP is on AWS?).

What did eventually work for us was this -

The below code change fixed the issue. Added this to the createTransport()

tls: {rejectUnauthorized: false}

Code:-

// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({ host: 'host', port: 25, secure : false, // true for 465, false for other ports auth: { user: 'user', pass: 'password' }, tls: { // do not fail on invalid certs rejectUnauthorized: false },
});

It seems that, in our providers case, their certificates do not cover all of the IPs they are being served from on AWS.

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like