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

@elara-services/mailer

v2.0.5

Published

An easy to use package to send emails or SMS messages via a Gmail account.

Downloads

19

Readme

Welcome to the @elara-services/mailer package!

This package allows you to send an SMS message or email via a Gmail account!

Getting Started

  • You need to get the clientId, clientSecret and refreshToken from your Google Cloud Platform account: Guide here
  • MAKE SURE TO ENABLE THE GMAIL API SERVICE ON YOUR GOOGLE CLOUD ACCOUNT!
const { Mailer } = require("@elara-services/mailer");
const mail = new Mailer("[email protected]", {
    username: `Elara Services: Mailer`, // Your custom name for who sent the email (NOTE: It will show your gmail account to the user you send stuff to!)
    clientId: "Your google apis client ID",
    clientSecret: "Your google apis client secret",
    refreshToken: "Your gmail refresh token",
});

Send SMS:

mail.phone("PHONE_NUMBER", "Text message here");
// By default: It will use 'us' as the region 
// By default: it will go through all of the carriers/providers to find the correct one to send it to if you don't provide a carrier when using the 'phone' function!

Send Email(s):

mail.email("[email protected]", {
    text: `Boop!`, // Optional
    subject: `Henlo!`, // Optional 
    html: `<html><body><h1>Beep!</h1></body></html>`, // Optional 
});
// NOTE: "text" or "html" is required! (one or the other has to be provided in order to work properly)

// Send the same info to multiple emails: 
mail.email([
    "[email protected]",
    "[email protected]",
    "...etc"
], {
    text: `Boop!`, // Optional
    subject: `Henlo!`, // Optional 
    html: `<html><body><h1>Beep!</h1></body></html>`, // Optional 
});

Server API

Getting Started

const { Server } = require("@elara-services/mailer");
const server = new Server({
    email: "[email protected]",
    options: {
        username: "Elara Services: Mailer",
        clientId: "your_client_id",
        clientSecret: "your_client_secret",
        refreshToken: "your_refresh_token",
    }
}, "API_KEY_HERE", 2020);
// "API_KEY_HERE" make sure to make the key secure! 
// Replace 2020 with whatever you want the API's port number to be! 
server.start(); // Make the server start listening for requests. 

Authorization:

  1. You need the Authorization header for all routes. (If you have the API key provided)

Send Endpoints:

Route: /email

Body:

{
    "email": "xxx",
    "subject": "Email Subject (OPTIONAL)",
    "text": "Text for the email",
    "html": "HTML code for the email (Use 'html' or 'text')"
}

Route: /sms

Body:

{
    "phone": "xxx",
    "text": "Text for the message"
}

Verification Endpoints:

Route: /verify/sms

Body:

{
    "phone": "123456789",
    "codeLength": 20, // Verification code length. (OPTIONAL, DEFAULT: 15)
}

Route: /verify/email

Body:

{
    "email": "xxxx",
    "codeLength": 20, // Verification code length. (OPTIONAL, DEFAULT: 15)
}

Verification Responses:

Success:

{
    "status": true,
    "code": "xxx"
}

Fail:

{
    "status": false,
    "message": "xxx"
}