mailgun-mailer
v2.2.0
Published
NodeJS module for use with Mailgun API
Downloads
6
Readme
mailer
Node scripts for using Mailgun.
mailer.js
exports as a module with functions to send each type of e-mail.
Messages can be formatted as HTML within in the html
parameter of each form.
Installation
npm install mailgun-mailer
Functions
setApiKey
: Set the API key
setDomain
: Set the domain (ie. fusiform.co)
setAddress
: Set the from address (ie. [email protected])
sendMail
: Send an email based on a specified HTML template (for newsletters, password reset notifications, etc.)
Parameters:
- name - string - name of recipient
- toAddress - string - recipient's email address
- subject - string - subject of email
- templateFile - string - path to HTML template of file
sendLink
: Send an email with a custom link (for email verification, password reset, etc.)
Parameters:
- name - string - name of recipient
- toAddress - string - recipient's email address
- subject - string - subject of email
- templateFile - string - path to HTML template of file
- link - string - link to insert into email template
sendReplace
: Send an email and specify parameters to replace (for email verification, password reset, etc.)
Parameters:
- name - string - name of recipient
- toAddress - string - recipient's email address
- subject - string - subject of email
- templateFile - string - path to HTML template of file
- toReplace - JSON - key-value pairs for strings to replace
Other functions
setAddress
: Set the from address (ie. [email protected])
welcome
: Send "Welcome" email
verifyEmail
: Send verification email for new account
passReset
: Send password reset link and instructions
passChanged
: Send notification that password was changed
tfaReset
: Send link and instructions to reset TFA settings
Example
var cred = {
'key': 'key-00001234',
'domain': 'sandbox1234.mailgun.org',
'address': '[email protected]'
};
//Whether or not to print debug messages
var debug = false;
var mailer = require('mailgun-mailer')(cred, debug);
mailer.sendLink('Pranav', '[email protected]', 'Welcome to FusiformCAST!', 'path/to/template/', 'www.verification_link.com/00001234');