Pomo Mailer
- Render multi-language mail with jade template.
- Mail queue based on MongoDB, send mail by local timezone.
- Manage cyclical task, resume from original progress when terminated.
- Built-in some useful templates.
- Mail agent using HTTP API.
require 'pomo-mailer'
Mailer
mailer = server: service: 'Postmark' auth: user: 'postmark-api-token' pass: 'postmark-api-token' from: 'Pomotodo <robot@pomotodo.com>' mailersendMail 'action''jysperm@gmail.com' title: 'Please confirm your email address' link: 'https://pomotodo.com' action: 'Confirm'then consolelogcatch consoleerror
Queue
queue = mailer: mailer mongodb: 'mongodb://localhost/pomo-mailer-test' queuepushMail template: 'billing' address: 'jysperm@gmail.com' locals: generateBillingthen consolelogcatch consoleerror
Agent
agent = queue: queue users: jysperm: 'pass' app = expressappuse bodyParserjsonappuse agentexpress
Task
task = name: 'weekly' worker: worker : -> momentformat 'YYYY-W' : -> momentstartOf'week'addweeks: 1 = return QPromise dbaccountsfind _id: $gte: taskprogress ? null sort _id: 1 then asynceach accounts notify _id mailersendMail 'weekly'emailgenerateWeekly then resolvereject
Built-in templates
action
alert
billing
Some useful templates converted from mailgun/transactional-email-templates.
Common fields:
-
title
{String} -
detail
{String} -
link
{String} -
action
{String} -
copyright
{String} -
unsubscribe
{Object}before
{String}link
{String}action
{String}after
{String}
alert
fields:
alert
{String}
billing
fields:
-
address
{Array} of {String} -
products
{Array}name
{String}price
{String}
-
total
{Object}name
{String}price
{String}