Can I use NodeMailer in strongloop to send emails?

789 Views Asked by At

I am trying to send email from strongloop. Am working in cloudnine platform online.

I tried using the simple code to send mail. But nothing is working.

2

There are 2 best solutions below

0
On

Here is a sample from a blog - 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: "[email protected]",
    pass: "userpass"
  }
})
 
if (process.env.NODE_ENV === 'production') { // [2]
  process.on('uncaughtException', function (er) {
    console.error(er.stack) // [3]
    transport.sendMail({
      from: '[email protected]',
      to: '[email protected]',
      subject: er.message,
      text: er.stack // [4]
    }, function (er) {
       if (er) console.error(er)
       process.exit(1) // [5]
    })
  })
}

Also which version of LoopBack are you using, see 2.0 release notes here - http://docs.strongloop.com/display/public/LB/LoopBack+2.0+release+notes

hth

2
On

Note that outgoing smtp is disabled on cloud9 (c9.io) for general usage. You can send to gmail addresses for testing or use the google, amazon, sendgrid, etc mailer APIs.