我想从带有 nodemailer 的 node.js 应用程序通过 Gmail (OAuth) 发送电子邮件。它在我的 PC 上运行良好,但如果我从我的 Linode 服务器上尝试,则没有任何反应。我没有收到错误,它只是在几分钟后超时。 防火墙被禁用,因为代码在我的本地机器上工作,我不知道从哪里开始。 也许有人知道从哪里开始并帮助我解决这个问题。
编辑:您必须联系 Linode 支持以解除 SMTP 限制:)
非常感谢!
答案 0 :(得分:0)
我在使用 nodemailer 从实时服务器发送邮件时也遇到了问题。 我能够使用此代码块发送邮件:
const nodemailer = require("nodemailer")
const transporter = nodemailer.createTransport({sendmail: true}, {
from: "no-reply@your-server.com",
to: "recipient@mail.com",
subject: "subject"
})
var contact;
transporter.sendMail({html: "<p>mail sent</p>"}, (error, info) => {
if(error){
console.log(error)
}
else {
console.log('Email sent: ' + info.response);
}
})