@grupojaque/mailer-jaque

1.0.0 • Public • Published

Mailer Jaque

Module for sending mails from an ejs template.

pipeline status coverage report

Setup

Requirements

Modules
  • Nodemailer: Used for sending the mail.
  • Ejs: Used for rendering the templates.

Initialization

Install with;

$ npm install mailer-jaque

Import in project.

const configObject = require('path/to/config.js');
const mailer = require('mailer-jaque')(configObject);

Configuration

Configuration values

The module needs the transport information in the configuration.

Key Description Example
transport.host Name of the email server to use 'smtp.ethereal.email'
transport.port Port to connect to transport.host 587
transport.auth.user Email user to use in he authentication 'iq3i4rreg4tnevnq@ethereal.email'
transport.auth.pass Email password to use in he authentication 'DejVytmSpYGrn52fEM'
viewsDir Relative route to the views to use (from the project root) 'views'
templates.template_name.view Name of the ejs file associated to the template template_name 'test'
templates.template_name.subject Subject to be used in the mail 'Company name - Formal subject'
from Remitent to be used in the email, this is a default and will be overwritten if this field is present in the mail options 'David Plowie'
testMode if true it will deactivate the mailing for testing purposes false

You can find a configuration example file here

Usage

send(options)

Will send an email.

  • options: Object containing the values to be used in the ejs rendering destinatary and html code or the name of the template to use. Optionally the Name of the remitent, and subject. Examples:
    {
      to: 'user@mail.com',
      template: 'test',
      data: { // Values to be used in the ejs rendering
        user: {
          name: 'Ayrton',
        },
        secret_token: 'czxcsdhsgrwgg43twf'
      }
    }
    {
     to: 'user@mail.com',
     from: 'Me',
     html: '<p> Hello there!</p>',
     subject: 'Hello'
    }

Errors

Errors will be instances of MailerError, wich extends the Error class

status message description
500 serverError Cant send mail without to
500 serverError Tamplate not found

Contributors

  • Emilio Martínez

Package Sidebar

Install

npm i @grupojaque/mailer-jaque

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

156 kB

Total Files

37

Last publish

Collaborators

  • emilio-mh
  • franciscomarquez
  • kuttkatrea
  • susuhahnml