Last active
May 25, 2016 09:36
-
-
Save andris9/9b85c04450363ada79dd11b57debb3af to your computer and use it in GitHub Desktop.
nodemailer test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var nodemailer = require('nodemailer'); | |
var smtp = require('nodemailer-smtp-transport'); | |
var options = { | |
service: 'gmail', | |
auth: { | |
user: 'username', | |
pass: 'password' | |
}, | |
logger: true, | |
debug: true | |
}; | |
var transport = nodemailer.createTransport(smtp(options)); | |
var mailer = function (options) { | |
return new Promise(function (resolve, reject) { | |
transport.sendMail(options, function (error, response) { | |
if (error) { | |
reject(error); | |
} else { | |
resolve(response); | |
} | |
}); | |
}); | |
}; | |
mailer({ | |
from: '[email protected]', | |
to: '[email protected]', | |
subject: 'test', | |
text: 'hello world' | |
}).then(function (resp) { | |
console.log(resp); | |
}).catch(function (err) { | |
console.error(err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment