我遇到了持续的困境,让nodemailer发送。现在,我找到了最低的安全电子邮件帐户,我可以查看是否可以让事情运行,以期在某些事情中获得解决方案,以提高安全性。我的代码是:
app.post("/contact-us", function(req, res){
var mailOpts, smtpTrans;
smtpTrans = nodemailer.createTransport({
host: 'smtp.123-reg.co.uk',
port: 25,
secure: false, // upgrade later with STARTTLS
auth: {
user: 'enquiries@*********.co.uk',
pass: '**********'
}
});
mailOpts = {
from: "enquiries@*******.co.uk",
to: "**********@mac.com",
subject: 'Website contact form',
text: "test email"
};
smtpTrans.sendMail(mailOpts, function (error, response) {
//Email not sent
if (error) {
console.log(error);
res.render('contact', { title: '********', msg: 'Error occured, message not sent.', err: true, page: 'contact-us' });
}
//Yay!! Email sent
else {
console.log("message sent");
res.render('/');
}
});
});
console.logs都没有返回,而是通过超时满足请求。502消息,
谢谢
以防万一任何人在将来搜索它;问题是在云9中,不允许访问电子邮件帐户以防止垃圾邮件。