emailjs-gmail

Send mail from a gmail account

Usage no npm install needed!

<script type="module">
  import emailjsGmail from 'https://cdn.skypack.dev/emailjs-gmail';
</script>

README

A wrapper for emailjs

Install

$ npm install --save emailjs-gmail

Initialize

// initialize to create the `send` function
const { send } = require('emailjs-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!');

Callback

  // send a message to an email (async)
  send('5555555555@txt.att.net', 'Aloha!', function myCallback(err, message) {
    console.log('message sent');
  });

Promise

  // send a message to an email (async)
  send('5555555555@txt.att.net', 'Aloha!').then(() => {
    console.log('message sent');
  });

Async/Await

(async () => {
  // send a message to an email (async)
  await send('5555555555@txt.att.net', 'Aloha!');
})();