我已经创建了用于发送邮件的节点API,但是当我触发该API时,出现错误无效登录。我在GoDaddy中有一个电子邮件帐户。
UnhandledPromiseRejectionWarning:未处理的承诺拒绝(拒绝ID:1):错误:无效的登录名:535用户信息@xxxx已被限制。
我的代码如下:
app.post("/mail", function(req, res) {
console.log("Server started.........");
var email = req.body.email;
var name = req.body.name;
var msg = req.body.subject;
console.log(email);
console.log(name);
console.log(msg);
var mail_to = "info@xxxx.xxx";
var text_fun = "Email-Id: " + email + "\n" +
"Name : " + name +"\n" +
"Message : " + msg +"\n";
var subject_fun = conf.subject;
mailSend(mail_to, text_fun, subject_fun).then((info, error) => {
console.log(error);
console.log("here");
console.log(info);
if (error) {
console.log(error);
return false;
}
console.log("here");
});
});
function mailSend(mail_to, text_fun, subject_fun = conf.subject) {
console.log("mailsend fucntion.....");
var Mail = nodemailer.createTransport({
service: "Godaddy",
host: "smtpout.secureserver.net",
secureConnection: true,
requireTLS: false,
tls: { cipher: "SSLv3" },
port: 465,
auth: {
user: "info@xxxx.xxx",
pass: "xxxxxxxxxx"
}
});
let mailSetup = {
from: conf.from_mail,
to: mail_to,
subject: subject_fun,
text: text_fun
};
// return Mail.sendMail(mailSetup);
return new Promise((resolve, reject) => {
Mail.sendMail(mailSetup, (err, data) => {
if (err) {
return reject(err);
} else {
return resolve(data);
}
});
});
}
我不知道为什么我会收到此错误,有人可以帮助我。