mailor
Mailer tools
Last updated 22 days ago by pateketrueke .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mailor 
SYNC missed versions from official npm registry.

Mailor

This module glues Maildev and MJML with some Pug and Mustache to enable an easier development workflow for mailings on NodeJS.

Build Status NPM version Coverage Status Known Vulnerabilities

Get it globally or within your project:

$ npm i -g mailor # or `npm i mailor --save-dev`

Use mailor init to create a templates/ directory with an example.pug ready play with!

Now, you can start creating templates using pure .pug files:

templates/test1.pug

mjml
  Body: Section
    Column: Text
      h1 It works!

Shortcuts for mj-* tags are provided as <Column /> to produce <mj-column /> respectively — those tags supports the class attribute by default while mj-* requires css-class instead.

Build or watch for changes, e.g.

$ mailor watch templates -d generated --no-open

Once built, try sending it through the local SMTP, e.g.

$ mailor send generated/test1.html

Open http://localhost:1081 and see how it looks!

LESS.js support

You can pre-process and embed the resulting stylesheet through LESS, e.g.

mjml
  Head
    Style(src='_your_stylesheets.less')

The src attribute used here is non MJML standard, so mj-style won't work the same way — also, if your file is not .less then it'll be embedded without changes.

Including files

By default all files or directories starting with _ are ignored by the compiler, e.g.

mjml
  Head
    include _/header

Live preview

Preview panel Input panel

The included live-preview app allows you to watch your generated templates, input variables are extracted directly from your templates so you can test with real data.

You can leverage on the jsonfile option to setup default variables too — notice that on Mustache some values can be objects, arrays or functions.

API

By default maildev is enabled when watch mode is used.

The send command uses nodemailer for sending messages through.

You can, however, reuse this module too:

const nodemailer = require('nodemailer');

const mailer = require('mailor').getMailer({
  transport: nodemailer.createTransport(...),
  internalErrors: [],
});

mailer.sendMail({
  template: 'path/to/tpl.html',
  subject: 'Test',
  email: 'test@example.com',
  data: { ... },
});

You MUST provide a working transport and optionally a list of internal error messages to be aware of, if any matches an exception will be thrown.

Using input

Local variables are given as data and they're rendered by Mustache to build the message to be sent.

Locals for pug-templates MUST be provided as values during mailor invocation, e.g.

$ mailor build templates -d generated username="John Doe" token="x-f4c8"

Current Tags

  • 0.2.2                                ...           latest (22 days ago)

32 Versions

  • 0.2.2                                ...           22 days ago
  • 0.2.1                                ...           23 days ago
  • 0.2.0                                ...           23 days ago
  • 0.1.5 [deprecated]           ...           23 days ago
  • 0.1.4                                ...           23 days ago
  • 0.1.3                                ...           23 days ago
  • 0.1.2                                ...           24 days ago
  • 0.1.1                                ...           4 months ago
  • 0.1.0                                ...           5 months ago
  • 0.0.23                                ...           5 months ago
  • 0.0.22                                ...           8 months ago
  • 0.0.21                                ...           10 months ago
  • 0.0.20                                ...           10 months ago
  • 0.0.19                                ...           10 months ago
  • 0.0.18                                ...           a year ago
  • 0.0.17                                ...           a year ago
  • 0.0.16                                ...           a year ago
  • 0.0.15 [deprecated]           ...           a year ago
  • 0.0.14                                ...           a year ago
  • 0.0.13                                ...           a year ago
  • 0.0.12                                ...           a year ago
  • 0.0.11                                ...           a year ago
  • 0.0.10                                ...           a year ago
  • 0.0.9                                ...           a year ago
  • 0.0.8                                ...           2 years ago
  • 0.0.7                                ...           2 years ago
  • 0.0.6                                ...           2 years ago
  • 0.0.5                                ...           2 years ago
  • 0.0.4                                ...           2 years ago
  • 0.0.3                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 88
Last Day 0
Last Week 0
Last Month 0
Dependencies (14)
Dev Dependencies (16)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |