0.1.4 • Published 8 years ago

warp.email-processor v0.1.4

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

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" 
    }
});
0.1.4

8 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

11 years ago

0.0.1

11 years ago