I have a mail server setup and working (dockerized dovecot/postfix on Linode, using the tvial docker image) - I can send and receive mail from both roundcube and the mail client on my macbook.
But setting up nodemailer with the same SMTP server and credentials, I get:
{ Error: queryA ECONNREFUSED mail.xxxxx.com
at errnoException (dns.js:50:10)
at QueryReqWrap.onresolve [as oncomplete] (dns.js:238:19)
code: 'EDNS',
errno: 'ECONNREFUSED',
syscall: 'queryA',
hostname: 'mail.xxxxx.com',
command: 'CONN' }
I'm using the sample script from the docs:
"use strict";
const nodemailer = require("nodemailer");
// async..await is not allowed in global scope, must use a wrapper
async function main(){
// Generate test SMTP service account from ethereal.email
// Only needed if you don't have a real mail account for testing
//let account = await nodemailer.createTestAccount();
// create reusable transporter object using the default SMTP transport
let transporter = nodemailer.createTransport({
host: "mail.xxxxx.com",
port: 465,
secure: true, // true for 465, false for other ports
auth: {
user: "[email protected]",
pass: "pppppp"
}
});
// setup email data with unicode symbols
let mailOptions = {
from: '"Fred Foo 👻" <[email protected]>', // sender address
to: "[email protected]", // list of receivers
subject: "Hello ✔", // Subject line
text: "Hello world?", // plain text body
html: "<b>Hello world?</b>" // html body
};
// send mail with defined transport object
let info = await transporter.sendMail(mailOptions)
console.log("Message sent: %s", info.messageId);
// Preview only available when sending through an Ethereal account
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
// Message sent: <[email protected]>
// Preview URL: https://ethereal.email/message/WaQKMgKddxQDoou...
}
main().catch(console.error);
I also get the same error without trying to send an email using:
transporter.verify((err, success) => {
if (err)
console.error(err);
else
console.log('Your config is correct');
});
Had the same problem. Just use a version earlier 5.0.0.
For install specific version use npm install package@version
In our case: npm install [email protected]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With