node package manager

hof-emailer

HOF Emailer

An emailer service for HOF applications.

Installation

$ npm install hof-emailer --save

Usage

// first create an emailer instance 
const Emailer = require('hof-emailer');
const emailer = new Emailer({
  from: 'sender@example.com',
  transport: 'smtp',
  transportOptions: {
    host: 'my.smtp.host',
    port: 25
  }
});
 
// then you can use your emailer to send emails 
const to = 'recipient@example.com';
const body = 'This is the email body';
const subject = 'Important email!'
emailer.send(to, body, subject)
  .then(() => {
    console.log(`Email sent to ${to}!`);
  });

Options

  • from: : address to send emails from. Required.
  • transport: : Defaults to 'smtp' - nodemailer-smtp-transport. Also available is 'ses' - nodemailer-ses-transport.
  • transportOptions: : Set the options for the chosen transport, as defined below. Required.
  • layout: : Optional path to use a custom layout for email content.

smtp options

nodemailer-smtp-transport

  • host : Address of the mailserver. Required.
  • port <String|Number>: Port of the mailserver. Required.
  • ignoreTLS : Defaults to false.
  • secure : Defaults to true.
  • auth.user : Mailserver authorisation username.
  • auth.pass : Mailserver authorisation password.

ses (AWS Simple Email Server API) options

nodemailer-ses-transport

  • accessKeyId : AWS accessKeyId. Required.
  • secretAccessKey : AWS accessKeyId. Required.
  • sessionToken
  • region . Defaults to 'eu-west-1'.
  • httpOptions
  • rateLimit
  • maxConnections