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 🙏

© 2024 – Pkg Stats / Ryan Hefner

curlymail

v1.1.4

Published

Lightweight email server with mustache templates support for messages.

Downloads

19

Readme

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: '[email protected]',
    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: '[email protected]',
    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: "[email protected], [email protected]",
    bcc: "[email protected]",
    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: '[email protected]',
    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