curlymail logo

Lightweight SMTP email server with mustaches

Star Fork Follow @jacoborus

curlyMail is a lightweight SMTP email server with mustache templates support for messages, it’s built on top of Hogan.js and Emailjs, and runs on Node.js

Usage example:

var curlymail = require('curlymail');

// add a email account and connect it to its SMTP server
curlymail.addAccount( 'main', {
    user: '',
    password: 'PA55W0RD'

// add a message template with mustaches
curlymail.addTemplate('weekly', {
    from:    '{{appname}}',
    to:      '{{username}} <{{email}}>',
    subject: 'Testing curlyMail',
    html:    '{{filename}} is ready for download',
    attachments: [
        {path:'path/to/photo.jpg', name:'renames.jpg'}

// data to render the template
var data = {
    username: 'Mr. Code',
    email: '',
    appname: 'curlymail co.',
    filename: 'Timetable',
    // _attachments in render data will be added
    // to message without being rendered
    _attachments: [
        {path:"path/to/", name:""}


npm install curlymail


Copy demo/accountSample.json in demo/account.json and add your mail account config to the new file. Then run:

npm run demo

curlymail API

addTemplate( key, template )

Add or overwrite a message template.

- key String: template keyname
- template Object: mail template

Curlymail use Hogan.js for template rendering. Uses the same headers Emailjs, but this adds the html message properly as an attached document and will generate text message from HTML if text not passed.


curlymail.addTemplate( 'welcomeMail', {
    from: '{{appname}}', // required
    to: '{{username}} <{{email}}>', // required
    cc: ',",
    bcc: '',
    subject: 'testing emailjs',
    html:    'Hello {{username}}!',
    text:    'Hello {{username}}!',
    attachments: [
        {path:'./', name:''}

addAccount( key, options )

Add an email account and connect it to its SMTP server.

- key String: keyname
- options Object: account credentials
- Return Object: curlymail

Returns curlyMail when finish, so you can chain methods
Same options as Emailjs

Connection options:


curlymail.addAccount( 'main', {
    user: '',
    password: 'PA55W0RD',
    host: '',
    ssl: true
}).addAccount( 'secondary', { ... });

send( account, template, data, callback )

Send message from a mail account

- account String: account key
- template String|Object: template key or template object
- data Object: data for template rendering
- callback Function: Signature: err, message


curlymail.send( 'mainAccount', 'welcomeMail', {}, function (err) {
    console.log( err || msg );

Note: _attachments field in data object will be added to message

Template rendering

See mustache

Email server connection and attachments options

See emailjs

Build docs

npm run build-docs

© 2015 Jacobo Tabernero - jacoborus

Released under MIT License