@everlast-brands/aws-email-sender
v3.1.0
Published
Wrapper for sending email with aws
Downloads
13
Readme
AWS Email Sender
Wrapper around @aws-sdk/client-ses
makes sending MJML
or HTML
email simple.
Installation
yarn add @everlast-brands/aws-email-sender
// or
npm install @everlast-brands/aws-email-sender
Setup
import express from "express";
import {EmailSender} from "@everlast-brands/aws-email-sender";
const app = express();
// add sender to the server req variable
app.use((req, res, next) => {
req.emailSender = new EmailSender({
region: process.env.AWS_REGION,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
accessKey: process.env.AWS_ACCESS_KEY_ID,
defaultSender: process.env.DEFAULT_SENDER // optional
});
})
// ...rest of app
Usage
app.post("/users", async (req, res) => {
// send html or mjml formatted emails
const htmlEmail = "<b>This is an email</b>";
const mjmlEmail = "<mjml code>" // string of mjml code https://documentation.mjml.io/
await req.emailSender.send({reciever: "[email protected]", subject: "This is the subject", markup: htmlEmail});
await req.emailSender.send({reciever: "[email protected]", subject: "This is the subject", markup: mjmlEmail});
});