Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

mai

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mai

send text/html e-mail with mail template management feature

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
0
Created
Source

Mai

Mai is an library to send emails, and attachments from node.js to any smtp server Mai also support load and management email template. Mai is built on node and emailjs.

Dependencies

Mai is compatible with node 0.4.x. Mai is depended emailjs

Installation

$ npm install mai

Features

  • E-Mail template management

Via emailjs:

  • works with SSL and TLS smtp servers (ex: gmail)
  • supports smtp authentication (PLAIN, LOGIN, CRAMMD5)
  • emails are queued and the queue is sent asynchronously
  • supports sending html emails and emails with multiple attachments (MIME)

Emaple

Prepare a email template text file named 'hello.txt' like below, and put it in the directory named 'templates'.

Hello, <%= value %>!

Followings is the code using above template file.

var Mai = require('mai'),
    conf, mai;

conf = {
    hostname: 'localhost',
    username: "",
    password: "",
    templatePath: __dirname + '/templates',
    encoding: 'utf-8'
};

mai = new Mai(conf);

mai.send({
    from: 'you@x.com',
    to: 'someone@x.com, another@x.com',
    subject: 'Hello Subject',
    templateName: 'hello', // templateName is a filename without extension
    params: {
        value: 'world'
    },
    callback: function(err, message) {
        if (err) {
            console.log('ERROR!');
        } else {
            console.log('SUCCESS');
        }
    }
});

For all, the variables in the template is replaced given value and you can see the mail body text is

Hello, world!

License

(The MIT License)

Copyright (c) 2011 Kazuyuki Honda hakobera@gmail.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

mail

FAQs

Package last updated on 12 May 2011

Did you know?

Socket

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