@macaw-email/provider-sendgrid

1.2.2 • Public • Published

Sendgrid provider for Macaw

Macaw is a simple library to streamline email templating.

Quickstart

Please start by looking at the Macaw documentation.

First install the Sendgrid provider package:

yarn add @macaw-email/provider-sendgrid

When initiating your instance of Macaw, pass in Sendgrid as your provider:

const sendgrid = require("@macaw-email/provider-sendgrid");

const mailer = macaw({
  provider: sendgrid({ apiKey: "aaaaa-bbbbbbb-ccccccc-ddddddd" })
});

You can find your API key in the Sendgrid developer console.

Then you can load a template and send it:

const template = await mailer.template("monthly-newsletter", {
  greeting: "Hello, world"
});

await template.send({
  subject: "Hello, world!",
  to: {
    name: "Thomas Schoffelen",
    email: "thomas@schof.co"
  },
  from: {
    name: "Mark from Startup X",
    email: "noreply@startup-x.com"
  }
});

The template.send() function accepts any parameters that are accepted by the Sendgrid Node API. It requires at least a subject, to and from field to be set.

/@macaw-email/provider-sendgrid/

    Package Sidebar

    Install

    npm i @macaw-email/provider-sendgrid

    Homepage

    macaw.email

    Weekly Downloads

    10

    Version

    1.2.2

    License

    MIT

    Unpacked Size

    3.82 kB

    Total Files

    4

    Last publish

    Collaborators

    • tschoffelen