Skip to content

Poddify/mailer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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'
    }
});

About

Lightweight email library using Mailgun

Resources

Stars

Watchers

Forks

Packages

No packages published