我正在使用 nodemailer ,我遇到了一个错误:
配置SMTP错误
我应该如何正确配置NodeMailer SMTP功能?
// create reusable transporter object using the default SMTP transport
let poolConfig = {
pool: true,
host: 'mail.smtp2go.com',
port: 2525,
secure: true, // use TLS
auth: {
user: 'usmanghany6@gmail.com',
pass: 'Usman12345'
}
};
// setup email data with unicode symbols
let mailOptions = {
from: '"Fred Foo 👻" <foo@example.com>', // sender address
to: 'upercase4@gmail.com, upercase4@gmail.com', // list of receivers
subject: 'Hello ✔', // Subject line
text: 'Hello world?', // plain text body
html: '<b>Hello world?</b>' // html body
};
可以在此处找到详细的SMTP NodeMailer配置文档:nodemailer_smtp_doc
注意:尝试运行以下配置验证以获取更详细的消息:
// verify connection configuration
transporter.verify(function(error, success){
if (error) {
console.log(error);
} else {
console.log('Ok message');
}
});