npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

mono-mail

v0.1.1

Published

Mails module for Mono

Downloads

12

Readme

Emails module for Mono

npm version Travis Coverage license

Installation

npm install --save mono-mail

Then, in your configuration file of your Mono application (example: conf/application.js):

module.exports = {
  mono: {
    modules: ['mono-mail']
  }
}

Configuration

mono-mail will use the mono.mail property of your configuration (example: conf/development.js):

module.exports = {
  mono: {
    mail: {
      exposeRoutes: true, // enabled by default on development environment
      provider: { // not required
        name: 'smtp || ses',
        ... //conf of the provider
      },
      from: '[email protected]', //sender email adress (required)
      smtp: // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/924fafffc09cfeb0267573af2c847cdbfcfa464d/types/nodemailer-smtp-transport/index.d.ts#L47
    }
  }
}

Providers

Mono mail is currently supporting two providers to send your email:

If no provider is provided the library will remove the /mails/send route and the send method.

Usage

Mono mail is a mono module that using mjml and handlebar to generate and send awesome mails.

const monoMail = require('mono-mail')

Mono mail also expose some methods as REST routes

TODO: All rest calls need a session and a role that contain manageMail action. This action is not added automatically.

Routes

The routes for preview and sending an email are only available on development environment or if the exposeRoutes is set to true in the configuration of the module.

Test preview route

Run the mono server with mono-mail

NODE_ENV=test npx mono dev test/fixture/ok

Once the server launched go to this url

Roadmap

  • Add attachment MINE Type in http POST route

Exposed routes

| Method | URI | Query params | Body | Action | | :------| :---| :------------| :-----| :--------| | GET | /mails/preview | path, data, pathType | | Return HTML Generated mail | | POST | /mails/send | pathType | path, data, to, subject | Send email |

Query params:

  • pathType?: String (relative or absolute) Relative from current mono instance dirname

Post/Query params:

  • path: String. Path to the mail file
  • data: Object. Data object that will be compiled by handlebar

Post params:

  • subject: String (compiled with handlebar). Subject of the mail
  • to: String. Email adress of the sender

Methods

registerPartial

registerPartial(partialName = String, partialPathmail = String): Promise<void>

Register new partial template to be used inside mail template

Arguments:

  • partialName: String. Partial name key
  • partialPathmail: String. Path of the partial template
// Register new partial
const template = await monoMail.registerPartial('font-footer', join(__dirname, 'modules/mails/font-footer.html'))

generate

generate(mail = { path, data, subject }): Promise<String>

Generate HTML template from mail object.

Arguments:

  • path: String. Path to the mail file
  • data: Object. Data object that will be compiled by handlebar
  • subject: String (compiled with handlebar). Subject of the mail
// Generate template mail in HTML
const template = await monoMail.generate({
  subject: 'Hello, {{ firstName }}',
  path: join(__dirname, 'modules/users/signup.html'),
  data: {
    title: 'Welcome to mono-mail',
    description: 'Mono module using mjml and handlebar to generate awesome template mail and send it to your customers'
  }
})

send

send(mail = { path, data, subject, bcc, to, attachments: [{ filename, path, contentType }] }): Promise<void>

Generate HTML template from mail object.

Arguments:

  • bcc: String. Blind Carbon Copy email
  • to: String. Recipient email address
  • attachments: Array<{ filename, path, contentType }>. Attachment to the mail
// Send email to [email protected] recipient
const template = await monoMail.generate({
  subject: 'Hello, {{ firstName }}',
  path: join(__dirname, 'modules/users/signup.html'),
  bcc: '[email protected]',
  to: '[email protected]',
  data: {
    title: 'Welcome to mono-mail',
    description: 'Mono module using mjml and handlebar to generate awesome template mail and send it to your customers'
  }
})

Development / Contribution

See the contribution guidelines of this project.

License

MIT © gaetansenn