Skip to content

Instantly share code, notes, and snippets.

@andris9
Last active May 25, 2016 09:36
Show Gist options
  • Save andris9/9b85c04450363ada79dd11b57debb3af to your computer and use it in GitHub Desktop.
Save andris9/9b85c04450363ada79dd11b57debb3af to your computer and use it in GitHub Desktop.
nodemailer test
'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