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

@sheetbase/gmail

v1.1.0

Published

Send email using Gmail in Sheetbase backend app.

Downloads

10

Readme

Sheetbase Module: @sheetbase/gmail

Send email using Gmail in Sheetbase backend app.

Build Status Coverage Status NPM License clasp Support me on Patreon PayPal Ask me anything

Install

Using npm: npm install --save @sheetbase/gmail

import * as Gmail from "@sheetbase/gmail";

As a library: 1cKQyLf_OZwivLAiNBw-naLV_uq-lmf8AcOEnE9t5E9IQhA1Fo8JTV_sm

Set the Indentifier to GmailModule and select the lastest version, view code.

declare const GmailModule: { Gmail: any };
const Gmail = GmailModule.Gmail;

Usage

  • Docs homepage: https://sheetbase.github.io/gmail

  • API reference: https://sheetbase.github.io/gmail/api

Getting started

Install: npm install --save @sheetbase/gmail

Usage:

import { gmail } from "@sheetbase/gmail";

const Gmail = gmail(
  /* options */ {
    prefix: "MyApp"
  }
);

const { threadId } = Gmail.send({
  recipient: "[email protected]"
});

Configs

forwarding

  • Type: string
  • Default: current account email.

Manage email from different account.

prefix

  • Type: string
  • Default: Sheetbase.

For better management, all email subject will be prefix with a string and labeled prefix:category.

categories

  • Type: object
  • Default: an uncategoriezed category: { uncategorized: { title: 'Uncategorized', silent: true } }.

List of support categories, all email will be sorted to one of these categories.

{
  categories: {
    message: 'Messages',
    misc: {
      title: 'Misc',
      silent: true
    }
  }
}

templates

  • Type: object
  • Default: {}.

List of supported templates.

{
  templates: {
    hello: (data: any) => `Hello ${data.name}!`,
  }
}

Gmail

Interface for sending email.

  • quota: view remaining daily quota.
  • send: send email.

quota

View remaining daily quota.

const { remainingDailyQuota } = Gmail.quota();

send

Send email.

// To: [email protected]
// Subject: Send me email
// Content: Hello world!
// Label: <prefix>:Uncategorized
const { threadId } = Gmail.send({
  recipient: "[email protected]",
  subject: "Send me email",
  options: {
    htmlBody: `<p>Hello world!</p>`
  }
});

// To: ...
// Subject: ...
// Content: ...
// Label: <prefix>:Messages
Gmail.send(
  {
    /* ... */
  },
  "message"
);

// To: ...
// Subject: ...
// Content: Hello John!
// Label: ...
Gmail.send(
  {
    recipient: "[email protected]",
    subject: "Send me email"
  },
  "message",
  {
    hello: { name: "John" }
  }
);

// force silent = false
Gmail.send(
  {
    /* ... */
  },
  null,
  null,
  false
);

Routes

To add routes to your app, see options AddonRoutesOptions:

Gmail.registerRoutes(options?: AddonRoutesOptions);

Default disabled

Disabled routes by default, to enable set { disabledRoutes: [] } in registerRoutes():

[
  "post:/mail" // send email
];

Endpoints

GET /mail

Get quota.

POST /mail

Send email. Route body:

  • mailingData: mail data
  • category: category name
  • template: template config
  • silent: override category silent

Send an email:

{
  mailingData: {
    recipient: '[email protected]',
    subject: 'Send me email',
    options: {
      htmlBody: `<p>Hello world!</p>`,
    }
  }
}

With category:

{
  mailingData: { /*  */ },
  category: 'message'
}

With template:

{
  mailingData: { /*  */ },
  template: {
    hello: { name: 'John' }
  }
}

Override category silent:

{
  mailingData: { /*  */ },
  silent: false,
}

License

@sheetbase/gmail is released under the MIT license.