@macaw-email/provider-sendgrid
v1.2.2
Published
Sendgrid provider adapter for Macaw.
Downloads
22
Readme
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: "[email protected]"
},
from: {
name: "Mark from Startup X",
email: "[email protected]"
}
});
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.