Tool of mail merge, which takes {{mustache}} email templates and data from json or csv to generate and bulk send emails.
- Generates emails from html templates based on handlebars
- Sends emails via NodeMailer
- Parse data defined in csv file and/or json as the context of emails
- Merge/combine multiple lines of rows in csv into one big record with array properties
- Use in your scripts and/or CLI
- Supports
.env
file for security related settings (i.e. SMTP connection url with your username & password)
npm install mail-merger --save
## use `mail-merger --help` for more details
$ mail-merger -c=./data.csv -t=./sample.html -a=./img1.png -a=./img2.png
import { MailMerger } from 'mail-merger';
// refer to `defaults.ts` for all details of the options
const merger = new MailMerger(opts);
// refer to `mail-merger.spec.ts` for more details
const summary = await merger.send(context, template, mailOpts);
console.info(`[${summary.sent}] out of [${summary.total}] emails were sent out successfully!`);
Please refer to the test files cli.spec.ts
and mail-merger.spec.ts
in the source code
MIT