1.0.0 • Published 25 days ago
sendgmailjs v1.0.0
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('5555555555@txt.att.net', 'Aloha!', "Google <no-reply@google.com>");
Callback
// send a message to an email (async)
send('5555555555@txt.att.net', 'Aloha!', function myCallback(err, message) {
console.log('message sent');
}, "Google <no-reply@google.com>");
Promise
// send a message to an email (async)
send('5555555555@txt.att.net', 'Aloha!').then(() => {
console.log('message sent');
}, "Google <no-reply@google.com>");
Async/Await
(async () => {
// send a message to an email (async)
await send('5555555555@txt.att.net', 'Aloha!', "Google <no-reply@google.com>");
})();
1.0.0
25 days ago