sendgmailjs
v1.0.0
Published
Send mail from a gmail account
Downloads
18
Maintainers
Readme
A wrapper for emailjs
Install
$ npm install --save send-gmail
Initialize
// 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
Simple
// send a message to an email (async)
send('[email protected]', 'Aloha!', "Google <[email protected]>");
Callback
// send a message to an email (async)
send('[email protected]', 'Aloha!', function myCallback(err, message) {
console.log('message sent');
}, "Google <[email protected]>");
Promise
// send a message to an email (async)
send('[email protected]', 'Aloha!').then(() => {
console.log('message sent');
}, "Google <[email protected]>");
Async/Await
(async () => {
// send a message to an email (async)
await send('[email protected]', 'Aloha!', "Google <[email protected]>");
})();