使用qq邮箱发送的时候
提示Error: connect EADDRNOTAVAIL
代码
var nodemailer = require("nodemailer");
var transport = nodemailer.createTransport("SMTP", {
host: "smtp.qq.com",
secureConnection: true, // use SSL
port: 465, // port for secure SMTP
auth: {
user: "22222[@qq](/user/qq).com",
pass: "343521,,"
}
});
transport.sendMail({
from: "<22222[@qq](/user/qq).com>",
to: "<737199641[@qq](/user/qq).com>",
subject: "Send by Node.js",
generateTextFromHTML: true,
html: "Send by Node.js!测试成功!!"
}, function(error, response) {
if (error) {
console.log('发送失败!' + error);
} else {
console.log("Message sent: " + response.message);
}
transport.close();
});
7 回复
我也发不出去,这可是参考cnodeClub的代码啊
mail_opts: {
host: 'smtp.qq.com',
port: 465,
secureConnection: true,
requiresAuth: true,
domains: ["qq.com"],
auth: {
user: '[email protected]',
pass: 'XX'
}
}
- Ubuntu 14.04 64位
- Node.js 0.10.29
- npm 1.4.14
- Nodemailer 0.7.1:
npm i [email protected]
。
然后执行上述代码,成功地从自己的QQ邮箱发送邮件到Gmail邮箱。