Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ampatspell/juicy-emails
Send emails built from Handlebars templates.
https://github.com/ampatspell/juicy-emails
email handlebars inlinecss nodejs nodemailer templates
Last synced: about 1 month ago
JSON representation
Send emails built from Handlebars templates.
- Host: GitHub
- URL: https://github.com/ampatspell/juicy-emails
- Owner: ampatspell
- License: mit
- Created: 2019-05-24T19:05:08.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-05-01T05:15:33.000Z (over 1 year ago)
- Last Synced: 2024-11-01T14:11:58.532Z (3 months ago)
- Topics: email, handlebars, inlinecss, nodejs, nodemailer, templates
- Language: JavaScript
- Homepage: https://github.com/ampatspell/juicy-emails
- Size: 68.4 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Juicy Emails 🍉
Send emails built from Handlebars templates.
* renders [handlebars](https://github.com/wycats/handlebars.js) template to html (supports partials and helpers)
* uses [juice](https://github.com/Automattic/juice) to inline css and images
* optionally generates plain text version using [html-to-text](https://github.com/werk85/node-html-to-text) from html
* renders subject [handlebars](https://github.com/wycats/handlebars.js) template
* sends email using [nodemailer](https://github.com/nodemailer/nodemailer)``` javascript
import JuicyEmails from 'juicy-emails';
import mailgun from 'nodemailer-mailgun-transport';
import path from 'path';const __dirname = path.dirname(new URL(import.meta.url).pathname);
const templates = path.join(__dirname, 'templates');const email = new JuicyEmails({
handlebars: {
templates, // required
helpers // optional
},
juice: {
preserveImportant: true,
webResources: {
// relativeTo:
images: 8
}
},
mailer: {
send: false, // sets transport to jsonTransport, defaults to true
from: 'Zeeba ', // default from, optional
transport: mailgun({ // defaults to { jsonTransport: true }
auth: {
api_key: '...',
domain: '...'
}
})
}
});let res = await email.send({
from, // defaults to mailer.from
to: '[email protected]',
name: 'hello',
props: {
name: 'Larry',
}
});
``````
templates
├── hello -- email name `email.send({ name, ... })`
| ├── html.hbs -- html template (required)
| ├── subject.hbs -- subject line (required)
| └── text.hbs -- plain text template (optional)
├── partials -- handlebars partials
| └── body.hbs
└── style.css
```Heavily influenced by [email-templates](https://github.com/niftylettuce/email-templates). Thank you [@niftylettuce](https://github.com/niftylettuce)