
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
mail-monkey
Advanced tools
[](https://travis-ci.org/ElderAS/mail-monkey) [](https://www.npmjs.com/package/mail-monkey

Plugin to simplify the mailing process with the help of MJML and Handlebars
npm install --save mail-monkey
const MailMonkey = require('mail-monkey')
/* This is the most simplest configuration, check out the docs for more features */
MailMonkey.config({
templateDir: 'YOURTEMPLATEFOLDER',
provider: {
name: 'Sendgrid',
key: 'YOURAPIKEY',
},
})
After you've configured MailMonkey you are ready to send off your mails, like this:
const MailMonkey = require('mail-monkey')
/* Assuming you have a template called Confirmation */
MailMonkey.Confirmation({
to: 'who@ever.org',
from: 'me@ofcourse.com',
subject: 'Check this out!',
data: {
name: 'Awesome...',
},
attachments: [
/* You get it ;) */
],
})
You can configurate MailMonkey anytime by calling:
MailMonkey.config({
/* Your config */
})
The following props are available for configuration:
Sets the mail provider. At the moment only Sendgrid is implemented but you can implement custom providers with the addProvider method (see below).
It should look like this:
MailMonkey.config({
provider: {
name: 'Sendgrid',
key: 'abc', //Your Sendgrid API Key
},
})
How to add your own provider
MailMonkey.addProvider('YOUR_PROVIDER_NAME', function(options) {
//options is the object passed in with the provider property when calling .config()
return {
send(data) {
//Send email with custom setup and return Promise
},
}
})
And after adding your custom provider you can use it in .config():
MailMonkey.config({
provider: {
name: 'YOUR_PROVIDER_NAME',
//Pass in anything you need to initialize
},
})
Set default settings for mail delivery.
Currently only sender is implemented. (more will come, feel free to send PR)
MailMonkey.config({
mailSettings: {
sender: {
email: '...', //All emails will use this address as sender, unless from is passed to mail function
},
},
})
Sometimes you need more features like helpers or partials.
You can do this with configure.
It should look like this:
MailMonkey.config({
handlebars: {
configure: function(hb) {
// Modify Handlebars instance (hb) here...
},
},
})
This is the path to you template directory. MailMonkey will read all files ending with .mjml and make them available. (CamelCase)
Example:
templates
- Confirmation.mjml --> MailMonkey.Confirmation
- sign-up.mjml --> MailMonkey.SignUp
- recover.mjml --> MailMonkey.Recover
MailMonkey.config({
templateDir: '/mail/templates',
})
If you have data that should be available in all templates you can provide it via defaultData.
Usually stuff like logo url etc.
It should look like this:
MailMonkey.config({
defaultData: {
company: {
name: 'Elder AS',
},
logo: 'path...',
},
})
If you would like to make your emails available at a given url you can solve it via server.
Currently only Express is supported.
It should look like this:
MailMonkey.config({
server: {
instance: EXPRESSAPP,
endpoint: '/mail', //All emails are available at /mail/TEMPLATENAME
resolver: function(req) {
//OPTIONAL
//Write your custom data resolver here
//This function should return your template data (async as Promise or sync Object)
//DEFAULT: returns req.query
},
},
})
server.endpoint uses the same syntax as Express. :template is reserved by mail-monkey and will be appended to your endpoint config if it isn't present.
Examples (template name is "confirmation")
endpoint: '/mail' -> available @ /mail/confirmation
endpoint: '/' -> available @ /confirmation
endpoint: '/mail/:template/:YOURID' -> available @ /mail/confirmation/YOURID
endpoint: '/mail/:YOURID/:template' -> available @ /mail/YOURID/confirmation
server.resolver can be used to resolve data you want to have accessible in your template. By default it returns QueryStrings via req.query.
You can enable logging by setting debug to true
The MIT License Copyright (c) Carsten Jacobsen
FAQs
[](https://travis-ci.org/ElderAS/mail-monkey) [](https://www.npmjs.com/package/mail-monkey
We found that mail-monkey demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.