我正在使用nodemailer发送电子邮件,但是我的防病毒软件阻止了nodemailer。当我关闭防病毒软件时,发送电子邮件没有问题。
有没有可能在不禁用防病毒的情况下使用nodemailer发送电子邮件的方法?
firebase.auth().onAuthStateChanged(function(user) {
if (user) {
// User is signed in.
var displayName = user.displayName;
var email = user.email;
var emailVerified = user.emailVerified;
var photoURL = user.photoURL;
var isAnonymous = user.isAnonymous;
var uid = user.uid;
var providerData = user.providerData;
// ...
} else {
// User is signed out.
// ...
}
});
错误消息->
const transporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
user: 'username@gmail.com',
pass: 'password'
}
});
var mailOptions = {
from: 'username@gmail.com',
to: "to',
subject: 'subject',
html: '<div></div>'
};
transporter.sendMail(mailOptions, function (error, info) {
if (error) {
console.log(error)
} else {
console.log('Email sent: ' + info.response);
}
});
答案 0 :(得分:1)
在您的transporter
设置中,尝试添加以下内容:
const transporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
user: 'username@gmail.com',
pass: 'password'
},
// === add this === //
tls : { rejectUnauthorized: false }
});
您现在应该可以在不禁用防病毒的情况下进行发送。