我正在尝试使用nodemailer的邮件API从microsoft azure上的express js服务器发送邮件。它在本地计算机上取得成功,但在 azure 服务器(远程)上却没有成功。有什么想法吗?
var mail = require("nodemailer").mail;
mail({from: "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f395819c9eb3949e929a9fdd909c9e" rel="noreferrer noopener nofollow">[email protected]</a>", // sender address
to: "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="36425976515b575f5a1855595b" rel="noreferrer noopener nofollow">[email protected]</a>", // list of receivers
subject: "subject", // Subject line
text: "text", // plaintext body
html: "<b>helloworld</b>" // html body
});
谢谢, AV
最佳答案
以防其他人遇到同样的问题。
我在 Azure 网站中运行 Nodemailer 时遇到了同样的问题。最后我发现问题是我忘记将Nodemailer作为package.json中的依赖项。然后 azure 不知道它必须为托管服务器安装 Nodemailer。
在 package.json 中的依赖项列表末尾添加 "nodemailer": "*"。在添加“nodemailer”之前,不要忘记在最后一行后添加“,”。
希望有帮助。
关于node.js - Nodemailer 的邮件在 Azure 服务器上无法工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23580754/