Send mail from a gmail account
npm install sendgmailjsA wrapper for emailjs
$ npm install --save send-gmail javascript
// initialize to create the send function
const { send } = require('send-gmail')(process.env.GMAIL_USERNAME, process.env.GMAIL_PASSWORD);
`> Note: Less secure app access must be enabled for the Gmail account sending mail.
Examples
$3
`javascript
// send a message to an email (async)
send('5555555555@txt.att.net', 'Aloha!', "Google ");
`$3
`javascript
// send a message to an email (async)
send('5555555555@txt.att.net', 'Aloha!', function myCallback(err, message) {
console.log('message sent');
}, "Google ");
`$3
`javascript
// send a message to an email (async)
send('5555555555@txt.att.net', 'Aloha!').then(() => {
console.log('message sent');
}, "Google ");
`$3
`javascript
(async () => {
// send a message to an email (async)
await send('5555555555@txt.att.net', 'Aloha!', "Google ");
})();
``