Last active
February 12, 2020 00:51
-
-
Save jgatjens/962cd0819056097b50bd73309a6ac608 to your computer and use it in GitHub Desktop.
Node and Gmail
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
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