@sidehackhq/mail

2.0.1 • Public • Published

sidehack-mail-js

Example

index.js

var Mailer = require('@sidehackhq/mail').Mail;
var TemplateEngine = require('@sidehackhq/mail/lib/TemplateEngine/EmailTemplates').EmailTemplatesTemplateEngine;
var Transport = require('@sidehackhq/mail/lib/Transport/Ses').SesTransport;
var path = require('path');

var mail = new Mailer({
	from: 'FROM',
	subject: 'sidehack-mail-js: testing',
	transport: new Transport({
		key: 'SES_KEY',
		secret: 'SES_KEY',
		amazon: 'https://email.REGION.amazonaws.com' // omitting this will default to `https://email.us-east-1.amazonaws.com`
	}),
	template: new TemplateEngine({
		path: path.join(__dirname, 'templates', 'test'), // points to `templates/test/`, `html.hbs` is required at this path
	}),
});

mail.send({
	to: 'TO', // string or array

	// when using templates, body is an object of parameters to be passed to the template engine
	body: {
		name: 'NAME',
		dob: 'DATE_OF_BIRTH',
	}
})
	.then(() => {
		console.log('Sent!');
	})
	.catch((err) => {
		console.log('Something went wrong!');
		console.log(err);
	})
;

templates/test/html.hbs

Hi {{name}}! Your date of birth is {{dob}}.

Readme

Keywords

none

Package Sidebar

Install

npm i @sidehackhq/mail

Weekly Downloads

0

Version

2.0.1

License

Apache-2.0

Last publish

Collaborators

  • jameswestnz