@poddify/mailer

0.0.3 • Public • Published

@poddify/mailer

A lightweight library for sending email using Mailgun

Installation

$ npm i --save @poddify/mailer

Usage

import Mailer from '@poddify/mailer';

const mailer = new Mailer({
    apiKey: MAILGUN_API_KEY,
    domain: MAILGUN_DOMAIN
});

mailer.send

Sends an email

Option Description
from from email address
to to email address
subject subject line
template email HTML
data template data

Example

mailer.send({
    from: FROM_EMAIL,
    to: TO_EMAIL,
    subject: SUBJECT,
    template: EMAIL_TEMPLATE,
    data: EMAIL_TEMPLATE_DATA
});

Email Templates

Email templates are expected to be HTML contents and are provided to mailer.send via the template parameter. The HTML string provided will be injected with data using the data parameter. To inject string data into your email body, simply add {{DATA_PARAM}} within the HTML contents, where DATA_PARAM is the object key in options.data

mailer.send({
    template: '<h1>{{title}}</h1>',
    data: {
        title: 'Hello World'
    }
});

Readme

Keywords

none

Package Sidebar

Install

npm i @poddify/mailer

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

7.58 kB

Total Files

9

Last publish

Collaborators

  • jordanforeman