我可以在strongloop中使用NodeMailer发送电子邮件吗?

我正尝试从strongloop发送电子邮件。 我在云端平台在线工作。

我试着用简单的代码来发送邮件。 但没有任何工作。

请注意,传出smtp在cloud9(c9.io)上是禁用的一般用法。 您可以发送到Gmail地址进行testing或使用谷歌,亚马逊,sendgrid等邮件API。

这是一个来自博客的示例 – http://strongloop.com/strongblog/robust-node-applications-error-handling/

Here is sample email alert template using nodemailer: var nodemailer = require('nodemailer') var transport = nodemailer.createTransport('SMTP', { // [1] service: "Gmail", auth: { user: "gmail.user@gmail.com", pass: "userpass" } }) if (process.env.NODE_ENV === 'production') { // [2] process.on('uncaughtException', function (er) { console.error(er.stack) // [3] transport.sendMail({ from: 'alerts@mycompany.com', to: 'alert@mycompany.com', subject: er.message, text: er.stack // [4] }, function (er) { if (er) console.error(er) process.exit(1) // [5] }) }) }