Socket
Socket
Sign inDemoInstall

curlymail

Package Overview
Dependencies
13
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    curlymail

Lightweight email server with mustache templates support for messages.


Version published
Weekly downloads
10
increased by233.33%
Maintainers
1
Install size
4.02 MB
Created
Weekly downloads
 

Readme

Source

curlyMail

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

curlymail.jacoborus.codes

Usage example:

var curlymail = require('curlymail');

// add a email account and connect it to its SMTP server
curlymail.addAccount( 'main', {
    user: 'username@domain.com',
    password: 'PA55W0RD'
});

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

// data to render the template
var data = {
    username: 'Mr. Code',
    email: 'curlymail@domain.com',
    appname: 'curlymail co.',
    filename: 'Timetable',
    // _attachments in render data will be added to message without being rendering
    _attachments: [
        {path:"path/to/file.zip", name:"timetable.zip"}
   ]
};

// send a message
curlymail.send( 'main', 'weekly', data, function (err, msg) {
    console.log( err || msg );
});

Installation

npm install curlymail

Demo

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.

Parameters:

  • 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.

Example:

curlymail.addTemplate( 'welcomeMail', {
    from: "{{appname}}", // required
    to: "{{username}} <{{email}}>", // required
    cc: "aperson@domain.com, otherperson@domain.com",
    bcc: "hideperson@domain.com",
    subject: "testing emailjs",
    html:    "<html>Hello {{username}}!</html>",
    text:    "Hello {{username}}!",
    attachments: [
        {path:"./file.zip", name:"renamed.zip"}
    ]
});

addAccount( key, options )

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

Parameters:

  • 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:

  • user: username for logging into smtp
  • password: password for logging into smtp
  • host: smtp host
  • port: smtp port (if null a standard port number will be used)
  • ssl: boolean or object {key, ca, cert} (if true or object, ssl connection will be made)
  • tls: boolean or object (if true or object, starttls will be initiated)
  • timeout: max number of milliseconds to wait for smtp responses (defaults to 5000)
  • domain: domain to greet smtp with (defaults to os.hostname)

Example:

curlymail.addAccount( 'main', {
    user: 'username@domain.com',
    password: 'PA55W0RD',
    host: 'smtp.gmail.com',
    ssl: true
}).addAccount( 'secondary', { ... });

send( account, template, data, callback )

Send message from a mail account

Parameters:

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

Example:

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

Keywords

FAQs

Last updated on 19 Nov 2015

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc