https://github.com/hackplan/pomo-mailer
Mail Renderer, Mail Queue, Task Manager
https://github.com/hackplan/pomo-mailer
Last synced: about 1 year ago
JSON representation
Mail Renderer, Mail Queue, Task Manager
- Host: GitHub
- URL: https://github.com/hackplan/pomo-mailer
- Owner: HackPlan
- License: mit
- Created: 2014-09-28T08:51:22.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-10-19T09:45:15.000Z (over 9 years ago)
- Last Synced: 2024-10-11T01:38:36.913Z (over 1 year ago)
- Language: HTML
- Homepage: https://www.npmjs.org/package/pomo-mailer
- Size: 55.7 KB
- Stars: 14
- Watchers: 14
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 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.
```coffee
{Mailer, Queue, Agent, Task} = require 'pomo-mailer'
```
## Mailer
```coffee
mailer = new Mailer
server:
service: 'Postmark'
auth:
user: 'postmark-api-token'
pass: 'postmark-api-token'
from: 'Pomotodo '
mailer.sendMail 'action', 'jysperm@gmail.com',
title: 'Please confirm your email address'
link: 'https://pomotodo.com'
action: 'Confirm'
.then console.log
.catch console.error
```
## Queue
```coffee
queue = new Queue
mailer: mailer
mongodb: 'mongodb://localhost/pomo-mailer-test'
queue.pushMail
template: 'billing'
address: 'jysperm@gmail.com'
locals: generateBilling()
.then console.log
.catch console.error
```
## Agent
```coffee
agent = new Agent
queue: queue
users:
jysperm: 'pass'
app = express()
app.use bodyParser.json()
app.use agent.express()
```
## Task
```coffee
task = new Task
name: 'weekly'
worker: worker
groupBy: -> moment().format 'YYYY-W'
nextGroup: -> moment().startOf('week').add(weeks: 1)
worker = (task) ->
return Q.Promise (resolve, reject, notify) ->
db.accounts.find
_id:
$gte: task.progress ? null
.sort
_id: 1
.then (accounts) ->
async.each accounts, ({_id, email, generateWeekly}) ->
notify _id
mailer.sendMail 'weekly', email, generateWeekly()
.then resolve, reject
```
## Built-in templates
* `action`
* `alert`
* `billing`
Some useful templates converted from [mailgun/transactional-email-templates](https://github.com/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}