This package has been deprecated

Author message:

hof-behaviour-emailer has been added directly into hof v19.0.1 <(^_^)> and should not be installed separately

hof-behaviour-emailer

2.2.1 • Public • Published

hof-behaviour-emailer

HOF behaviour to send emails

Usage

const EmailBehaviour = require('hof-behaviour-emailer');

// configure email behaviour
const emailer = EmailBehaviour({
  transport: 'ses',
  transportOptions: {
    accessKeyId: '...',
    secretAccessKey: '...'
  },
  template: path.resolve(__dirname, './views/emails/confirm.html'),
  from: 'confirmation@homeoffice.gov.uk',
  recipient: 'customer-email',
  subject: 'Application Successful'
});

// in steps config
steps: {
  ...
  '/confirm': {
    behaviours: ['complete', emailer],
    next: '/confirmation',
    ...
  },
  ...
}

Options

In addition to the options passed to hof-emailer, the following options can be used:

  • recipient - Required - defines the address to which email will be sent. This can be set either as a key to retrieve an email address from the session, or explicitly to an email address.
  • template - Required - defines the mustache template used to render the email content.
  • subject - defines the subject line of the email.
  • parse - parses the session model into an object used to populate the template.

recipient and subject options can also be defined as functions, which will be passed a copy of the session model and a translation function as arguments, and should return a string value.

// use a translated value for the email subject line
const emailer = EmailBehaviour({
  // ...
  subject: (model, translate) => translate('email.success.subject')
});

Readme

Keywords

Package Sidebar

Install

npm i hof-behaviour-emailer

Weekly Downloads

5

Version

2.2.1

License

MIT

Unpacked Size

15.9 kB

Total Files

15

Last publish

Collaborators

  • temitopeayoku
  • mdev246
  • vinodha.s
  • chisomoguibe
  • robertmccann
  • rhyad-zergane-ho
  • rhodine
  • mohameduwais
  • lennym
  • easternbloc
  • joefitter
  • coupey
  • sulthan-ahmed
  • andrew.moody.ho
  • aswann
  • robertdeniszczyc2
  • agraham19
  • aaron.robinson
  • sarahjaneluff
  • cmedland
  • hof-bot-user