npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

simple-gmail-sender

v1.0.0

Published

Simple library to send emails using gmail

Downloads

3

Readme

Simple Gmail Sender

This library allows you to send emails through your gmail account from node.
nodemailer is used behind the scenes as it's simply an abstraction over nodemailer for gmail.

Installation

Simply run the following command:

npm install simple-gmail-sender

This library includes Typescript typing.

Usage

the usage of the library is fairly straightforward:

import { GmailSender } from 'simple-gmail-sender'

const gmail = new GmailSender('[email protected]', 'your-password')

// you can call sendMail function without any params.
// an empty mail will be sent your own address.
gmail.sendMail()

// you can set the destination of the mail.
gmail.sendMail({ to: '[email protected]' })

// you might send a given mail to multiple destinations.
gmail.sendMail({ to: ['[email protected]', '[email protected]'] })

// all params are optionals (only a subset is displayed in this example).
gmail.sendMail({to: '[email protected]', text: 'Some Text', subject: 'Nice Subject', from: '[email protected]'})

in cases where you want to send mails without creating a new GmailSender instance
you might use the function sendThroughGmail as such:

import { sendThroughGmail } from 'simple-gmail-sender'

// this functions takes the same params as the "GmailSender.sendMail" function,
// except that you have to supply the "user" and "password" params.
sendThroughGmail({user: '[email protected]', password: 'your-password', to: '[email protected]', text: 'Some Text'})

you will get back a promise from calling either sendThroughGmail or GmailSender.sendMail (which resolves to the same response):

import { sendThroughGmail, SentMessageInfo } from 'simple-gmail-sender'

sendThroughGmail({ user: '[email protected]', password: 'your-password' })
  .then((result: SentMessageInfo) => {
    console.log(result.response)
  })
  .catch((error: Error) => {
    console.log(error)
  })

Security

It is not advised to use your own password for sending emails. since gmail will block by default any plain-text password that you'll send to it.
you have 2 options to resolve this issue:

  1. (Less Recommended) You might allow gmail to accept your plain-text password (called less secure apps): https://myaccount.google.com/lesssecureapps
    NOTE: this setting is not available for accounts with 2-Step Verification enabled.

  2. (Recommended) You might create a single-use password for your node app (called app passwords) through:
    https://myaccount.google.com/apppasswords
    after generating a single use password, use it instead of your own real password.
    NOTE: app passwords can only be used with accounts that have 2-Step Verification turned on.