textmail
Send emails using mailgun and plain text templates
installation
$ npm install textmail
usage
First create a mailer with some configuration:
var TextMail = ; var mailer =
Now you have a mailer - you can create 'emails' - these are functions that can be run to send the content to a recipient.
// create an email object that will render 'contact.txt' and // send it to 3 people with 'Contact Form Submission' as the subject var contact = mailer; app
The templates are ejs files - this means you can pass data from the vars:
This is an email template for <%= title %>
It can also access root vars: <%= num %>
api
TextMail(options)
Create a new mailer with the following options:
- domain - your mailgun account domain
- key - your mailgun account key
- template_root - the folder to search for templates
- vars - vars to render for every template
var email = mailer.create(template, subject, to_emails)
Create a new email that will be sent to each email in the to_emails array.
The template can be a path relative to the 'template_root' or can be a full path.
The template is rendered using ejs.
email(from_address, vars, callback)
Send the email by running it as a function passing the from address and the extra variables to render into the template
email(from_address, to, vars, callback)
Add an extra email (or array of emails) to the list of address the email is sent to
license
MIT