node.js - Nodemailer 的邮件在 Azure 服务器上无法工作

标签 node.js azure express nodemailer

我正在尝试使用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/

相关文章:

node.js - 如何让 Elasticsearch 与 MongoDb 和 node.js 一起玩?

javascript - 我怎样才能要求用户打开他们的蓝牙?使用javascript

javascript - 查找并替换 Json 文件中的项目

azure - Visual Studio 2013 Azure 发布配置文件相同的 Azure 帐户但不同的开发人员

javascript - Q.defer() 和 Promise() 的区别

azure - 如何生成没有过期的访问 token

java - 使用 Java 访问 IoT 中心 Azure 中的数据

javascript - 从 javascript 中调用快速路由

javascript - 如何在 Node.js 中从不同的应用程序注入(inject)模块

Node.js 流文件上传为文件夹构建