Skip to content

Instantly share code, notes, and snippets.

@jgatjens
Last active February 12, 2020 00:51
Show Gist options
  • Save jgatjens/962cd0819056097b50bd73309a6ac608 to your computer and use it in GitHub Desktop.
Save jgatjens/962cd0819056097b50bd73309a6ac608 to your computer and use it in GitHub Desktop.
Node and Gmail
if (process.env.GMAIL_PASS) {
var fromEmail = '[email protected]';
var fromPassword = process.env.GMAIL_PASS;
var toEmail = [
'[email protected]',
'[email protected]'
];
// Defined transport
var transporter = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: fromEmail,
pass: fromPassword
}
});
transporter.sendMail({
from: fromEmail,
to: toEmail,
subject: 'Deploy clientwebsite.com - successfully',
text: 'Please visit http://clientwebsite.com/ for new changes.',
html: '<p>Please visit http://clientwebsite.com/ for new changes.</p>'
}, function(error, response){
if(error){
console.log('Failed in sending mail');
}else{
console.log('Successfully send email');
}
});
} else {
console.log('please define env variable GMAIL_PASS ej: export GMAIL_PASS=password >> ~/.profile');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment