Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/psirenny/derby-email
Create emails using Derby JS apps/templates.
https://github.com/psirenny/derby-email
Last synced: 24 days ago
JSON representation
Create emails using Derby JS apps/templates.
- Host: GitHub
- URL: https://github.com/psirenny/derby-email
- Owner: psirenny
- Created: 2014-08-18T17:56:35.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-11-23T16:05:13.000Z (about 9 years ago)
- Last Synced: 2024-11-06T16:17:00.146Z (about 1 month ago)
- Language: JavaScript
- Size: 14.6 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-derby - derby-email - Create emails using Derby JS apps/templates (Information)
README
Derby Email
===========Create emails using [Derby JS](http://derbyjs.com) apps/templates.
It uses [derby-render](https://github.com/psirenny/derby-render) to render views and [juice](https://github.com/Automattic/juice) to inline styles.[![Build Status](https://travis-ci.org/psirenny/derby-email.png?branch=master)](https://travis-ci.org/psirenny/derby-email)
For convenience, the default results returned match the values read by [nodemailer](https://github.com/andris9/Nodemailer).
Installation
------------$ npm install derby-email --save
Usage
-----Create your views:
**index.html**
{{unescaped $formatEmail('app', '[email protected]')}}
Some text.
Some text.Any view named after a field and capitalized will be returned as a result.
**other.html**
Hello {{user}}
foo bar
foo barSend your email:
var derby = require('derby');
var app = derby.createApp('app', __filename);
var email = require('derby-email')(app);
var nodemailer = require('nodemailer');
app.loadViews(...);
app.loadStyles(...);function send(err, emailOptions) {
var transporter = nodemailer.createTransports(...);
transporter.send(emailOptions, function (err, info) {
...
})
};// return email options
email(send);// with data
var data = {_page: {userId: '...'}};
email(data, send);// with a specific page (namespace)
email('welcome', send);// or with both
email('welcome', data, send);View Functions
--------------The following view functions are available in your views:
**$formatEmail(name, address)** – Returns a formatted email address. i.e. `name `.
Options
-------All options are also passed in to derby-render. See [derby-render](https://github.com/psirenny/derby-render) for a list of options.
**fields** – The fields (views) to render and return. Includes: html, text, subject, from, to, etc. See [Nodemailer](https://github.com/andris9/Nodemailer) for a list of suggested fields.
**css** – Configuration options passed to inline-css. See [inline-css]https://github.com/jonkemp/inline-css).