3.1.0 • Published 6 months ago

@everlast-brands/aws-email-sender v3.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

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: "reciever@example.com", subject: "This is the subject", markup: htmlEmail});
  await req.emailSender.send({reciever: "reciever@example.com", subject: "This is the subject", markup: mjmlEmail});
});
3.0.2

6 months ago

3.1.0

6 months ago

3.0.1

7 months ago

3.0.0

2 years ago

2.1.0

2 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.0

3 years ago