The nodemailer author has made clear he's not supporting promises. I thought I'd try my hand at using bluebird, but my attempt at it doesn't seem to catch any errors that Nodemailer throws:
var nodemailer = require('nodemailer');
var Promise = require('bluebird');
// build the transport with promises
var transport = Promise.promisifyAll( nodemailer.createTransport({...}) );
module.exports = {
doit = function() {
// Use bluebird Async
return transport.sendMailAsync({...});
}
}
Then I call it by doing:
doit().then(function() {
console.log("success!");
}).catch(function(err) {
console.log("There has been an error");
});
However, when providing an invalid email, I see this:
Unhandled rejection Error: Can't send mail - all recipients were rejected
So, the nodemailer error isn't being caught by my bluebird promise. What have I done wrong?