Reputation: 1929
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');
});
Upvotes: 5
Views: 5287
Reputation: 201
I had the similar issue while sending bulk mail via generating html file. It caused for me because Linux has limit on number of open files which was blocking on opening email template with each mail.
Default limit on Linux is 1024. command to check: ulimit -n
To raise the number of open files limit to up to 10000: ulimit -n 10000 (I have set upto 10000)
To raise the number of open file limit in current shell: ulimit -s 10000
In case: you get permission error: you will need to raise the allowed limit in the /etc/limits.conf or /etc/security/limits.conf file (where the file is located depends on your specific Linux distribution).
For example to allow anyone on the machine to raise their number of open files up to 10000 add the line to the limits.conf file.
* hard nofile 10000
Then logout and relogin to your system and you should be able to do:
ulimit -n 10000
without a permission error.
It has resolved my issue. I have found solution here: changing number of open files limit @will
Upvotes: 1
Reputation: 151
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]
Upvotes: 14