Switch branches/tags
moleculer-twilio@1.0.10 moleculer-twilio@1.0.9 moleculer-twilio@1.0.8 moleculer-twilio@1.0.7 moleculer-twilio@1.0.6 moleculer-twilio@1.0.5 moleculer-twilio@1.0.4 moleculer-twilio@1.0.3 moleculer-twilio@1.0.2 moleculer-twilio@1.0.1 moleculer-twilio@1.0.0 moleculer-slack@1.1.0 moleculer-slack@1.0.0 moleculer-mail@1.2.1 moleculer-mail@1.2.0 moleculer-mail@1.1.1 moleculer-mail@1.1.0 moleculer-mail@1.0.8 moleculer-mail@1.0.7 moleculer-mail@1.0.6 moleculer-mail@1.0.5 moleculer-mail@1.0.4 moleculer-mail@1.0.3 moleculer-mail@1.0.2 moleculer-mail@1.0.1 moleculer-mail@1.0.0 moleculer-fake@1.0.12 moleculer-fake@1.0.11 moleculer-fake@1.0.10 moleculer-fake@1.0.9 moleculer-fake@1.0.8 moleculer-fake@1.0.7 moleculer-fake@1.0.6 moleculer-fake@1.0.5 moleculer-fake@1.0.4 moleculer-fake@1.0.3 moleculer-fake@1.0.2 moleculer-fake@1.0.1 moleculer-fake@1.0.0 moleculer-elasticsearch@1.1.1 moleculer-elasticsearch@1.1.0 moleculer-elasticsearch@1.0.6 moleculer-elasticsearch@1.0.5 moleculer-elasticsearch@1.0.4 moleculer-elasticsearch@1.0.3 moleculer-elasticsearch@1.0.2 moleculer-elasticsearch@1.0.1 moleculer-elasticsearch@1.0.0 moleculer-db@0.6.3 moleculer-db@0.6.2 moleculer-db@0.6.1 moleculer-db@0.6.0 moleculer-db@0.5.2 moleculer-db@0.5.1 moleculer-db@0.5.0 moleculer-db@0.4.5 moleculer-db@0.4.4 moleculer-db@0.4.3 moleculer-db@0.4.2 moleculer-db@0.4.1 moleculer-db@0.4.0 moleculer-db@0.3.3 moleculer-db@0.3.2 moleculer-db@0.3.1 moleculer-db@0.3.0 moleculer-db@0.2.0 moleculer-db@0.1.3 moleculer-db@0.1.2 moleculer-db@0.1.1 moleculer-db@0.1.0 moleculer-db-adapter-sequelize@0.1.4 moleculer-db-adapter-sequelize@0.1.3 moleculer-db-adapter-sequelize@0.1.2 moleculer-db-adapter-sequelize@0.1.1 moleculer-db-adapter-sequelize@0.1.0 moleculer-db-adapter-mongoose@0.4.4 moleculer-db-adapter-mongoose@0.4.3 moleculer-db-adapter-mongoose@0.4.2 moleculer-db-adapter-mongoose@0.4.1 moleculer-db-adapter-mongoose@0.4.0 moleculer-db-adapter-mongoose@0.3.1 moleculer-db-adapter-mongoose@0.3.0 moleculer-db-adapter-mongoose@0.2.0 moleculer-db-adapter-mongoose@0.1.2 moleculer-db-adapter-mongoose@0.1.1 moleculer-db-adapter-mongoose@0.1.0 moleculer-db-adapter-mongo@0.1.4 moleculer-db-adapter-mongo@0.1.3 moleculer-db-adapter-mongo@0.1.2 moleculer-db-adapter-mongo@0.1.1 moleculer-db-adapter-mongo@0.1.0 moleculer-bull@0.2.2 moleculer-bull@0.2.1 moleculer-bull@0.2.0 moleculer-bull@0.1.8 moleculer-bull@0.1.7 moleculer-bull@0.1.6 moleculer-bull@0.1.5 moleculer-bull@0.1.4 moleculer-bull@0.1.3
Nothing to show
Find file History
icebob Publish
 - moleculer-bee-queue@0.1.5
 - moleculer-bull@0.2.2
 - moleculer-elasticsearch@1.1.1
 - moleculer-fake@1.0.12
 - moleculer-mail@1.2.1
 - moleculer-slack@1.1.0
 - moleculer-twilio@1.0.10
Latest commit 9428eb0 Aug 3, 2018
Failed to load latest commit information.
examples reorg packages Jul 20, 2017
src add createTransport method & update deps Mar 28, 2018
test/unit fix tests Aug 3, 2018
.gitignore reorg packages Jul 20, 2017
CHANGELOG.md update changelog Mar 28, 2018
LICENSE rename org Feb 28, 2018
README.md update deps Aug 3, 2018
index.js rename org Feb 28, 2018
package-lock.json update deps Aug 3, 2018
package.json Publish Aug 3, 2018


Moleculer logo

moleculer-mail NPM version

Send emails with nodemailer. Support localized templates.



$ npm install moleculer-mail --save


$ yarn add moleculer-mail


Send an HTML e-mail with Gmail

"use strict";

const { ServiceBroker } = require("moleculer");
const broker = new ServiceBroker();

// Load service
broker.createService(require("moleculer-mail"), {
    settings: {
        from: "sender@moleculer.services",
        transport: {
            service: 'gmail',
            auth: {
                user: 'gmail.user@gmail.com',
                pass: 'yourpass'

// Send an e-mail
broker.call("mail.send", { 
    to: "john.doe@example.org", 
    subject: "Hello Friends!", 
    html: "This is the <b>content</b>!"

Send an e-mail with mailgun with Cc & Bcc

// Load service
broker.createService(require("moleculer-mail"), {
    settings: {
        transport: {
            service: "mailgun",
            auth: {
                api_key: 'api12345',
                domain: 'domain.com'

// Send an e-mail to some people
broker.call("mail.send", { 
    to: "john.doe@example.org", 
    cc: "jane.doe@example.org",
    bcc: "boss@example.org",
    subject: "Hello Friends!", 
    text: "This is a text only message!"

Send an e-mail from template

// Load service
broker.createService(require("moleculer-mail"), {
    settings: {
        transport: {
            type: "sendmail"
        templateFolder: "./email-templates",

        // Global data for templates
        data: {
            siteName: "My app"

// Send a welcome template
broker.call("mail.send", { 
    to: "john.doe@example.org", 
    template: "welcome",
    locale: "de-DE",
    data: {
        name: "John Doe",
        username: "john_doe",
        verifyToken: "123456"


Property Type Description
from String Sender's default email address. Use it if missing from ctx.params
transport Object Transport settings. Send to nodemailer.createTransporter
htmlToText Boolean Enable html-to-text conversion
templateFolder String Path to template folder
data Object Global data for templates

Transport options

Read more from transport options

Localized templates

The service support templates. It uses email-templates library. The templates is rendered by consolidate.js, so you can use many template engines.

Read more about template files.

Read more about localized templates or check the examples folder.


Name Params Result Description
mail.send Any field from here Object Send an email.


$ npm test

In development with watching

$ npm run ci


The project is available under the MIT license.


Copyright (c) 2016-2018 MoleculerJS

@moleculerjs @MoleculerJS