我有一个邮件服务器设置和工作(上的Linode dockerized的dovecot /后缀,使用tvial泊坞窗图片) - 我可以发送和来自roundcube和我的MacBook上的邮件客户端接收邮件。
但是,建立nodemailer用相同的SMTP服务器和凭据,我得到:
{ 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' }
我使用的是从文档的示例脚本:
"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);
我也得到了同样的错误,但不尝试发送使用电子邮件:
transporter.verify((err, success) => {
if (err)
console.error(err);
else
console.log('Your config is correct');
});
我有类似的问题,同时通过生成HTML文件群发邮件。这引起了我因为Linux对产品,其阻断与每个邮件打开电子邮件模板打开的文件数量的限制。
在Linux上默认的限额为1024的命令检查:的ulimit -n
为了提高打开的文件数限制为最多10000:的ulimit -n 10000(我已高达10000)
为了提高打开的文件数量限制在当前shell:-s的ulimit 10000
如果:你获得许可错误:你将需要提高在/etc/limits.conf或/etc/security/limits.conf文件中允许的界限(位于文件依赖于特定的Linux发行版)。
例如,为了让机器上的任何人,以提高他们的打开的文件数高达10000行添加到limits.conf文件。
* hard nofile 10000
然后注销并重新登录到你的系统,你应该能够做到:
的ulimit -n 10000
没有权限错误。
它解决了我的问题。我发现这里的解决方案:changing number of open files limit @will