Socket
Book a DemoInstallSign in
Socket

warp.email-processor

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

warp.email-processor

Queue and bulk send emails. Supports HTML and text templates

latest
Source
npmnpm
Version
0.1.4
Version published
Maintainers
1
Created
Source

warp.email-processor

Overview

warp.email-processor allows to queue and bulk-send emails. It supports HTML and text templates and consists of two methods: 1. queue - adds email metadata to a mongoDB collection; 2. process - sends all the unprocessed emails using the metadata from mongoDB;

Changes

0.0.4 - SendGrid support, settings object format changes

Usage

Create instance of email-processor

EmailProcessor = require('warp.email-processor');
email = new EmailProcessor({
	relativeTemplatesPath: 'path/to/your/templates/',
	collection: db.collection('emails'),
	service: 'Gmail',
	auth: {
		user: 'example@gmail.com',
		pass: 'secret'
	}
	}
});

*warp.email-processor uses nodemailer module, check the module description for an explanation of service settings.

Queue some emails

email.queue({recipient: 'recipient@example.com', sender: 'sender@example.com', subject: 'hello' , optionalKey1: 'foo', optionalKey2: 'bar'}, 'marketingTemplate', function(err){
    if (err) {
       console.log(err);
    }
    else {
    	 console.log('email is ready to be sent');
    }
});

Prepare your template

Put the following html into path/to/your/templates/marketingTemplate/index.html

<table >
	<tr>
		<td>
			Buy what we sell! It is really good! Especially !!optionalKey1!! and !!optionalKey2!!.
		</td>
	</tr>
</table>

This will result in:

<table >
	<tr>
		<td>
			Buy what we sell! It is really good! Especially foo and bar.
		</td>
	</tr>
</table>

Process (send your emails)

email.process(function(err) {
	if (err){
		console.log(err);
	}
	else {
		console.log('all emails are sent!');
	}
});

Using Sendgrid

The only difference is the options object passed:

EmailProcessor = require('warp.email-processor');
email = new EmailProcessor({
	relativeTemplatesPath: 'path/to/your/templates/',
	collection: db.collection('emails'),
	service: 'Sendgrid', //!!
	auth: {
		user: 'username',
		pass: 'secret'
	},
	// optionally you can pass request parameter which will be passed to sendgrid npm module, which in turn passes in to the request npm module
	// for example to use proxy:
	request: {
    	proxy: "http://localproxy:3128" 
    }
});

Keywords

email

FAQs

Package last updated on 18 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts