• Stars
    star
    113
  • Rank 310,115 (Top 7 %)
  • Language
    JavaScript
  • Created over 14 years ago
  • Updated over 13 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This SMTP client library for Node.JS helps you send email safely and easily.

Node Mail

This SMTP client helps you send email safely and easily using Node.JS. It supports TLS and auth-login so you can send through gmail. It also implements sanity checks to safeguard against header injection attacks.

Installation

Use NPM to install:

npm install mail

Sending Mail

The Mail class encapsulates connection settings and can be used as a safe, high-level mailer.

var mail = require('mail').Mail({
  host: 'smtp.gmail.com',
  username: '[email protected]',
  password: '**password**'
});

Use the mailer to send messages:

mail.message({
  from: '[email protected]',
  to: ['[email protected]'],
  subject: 'Hello from Node.JS'
})
.body('Node speaks SMTP!')
.send(function(err) {
  if (err) throw err;
  console.log('Sent!');
});

Mail(options)

Create a new mailer that can be used to send messages. Common options include:

  • host: server hostname
  • username: user for server authentication
  • password: password for server authentication,

Other options:

  • secure: true, false, or crypto credentials (default: true)
  • port: server listens on this port (default: 587 or 25)
  • domain: the domain of the sender (default: os.hostname())
  • mimeTransport: 7BIT or 8BITMIME (default: 8BITMIME)

Mail.message(headers)

Begin a MailTransaction. The headers object may contain any any SMTP headers. When the message is formatted, email addresses are validated, header names are title-cased, and header values escaped to prevent injection. A Date header is automatically added.

An email address may be an array, a single address, or a string with command-separated addresses. Individual addresses may be bare or in the format "Display Name" <[email protected]>.

MailTransaction.body(text)

Add a body to a mail transaction. Long lines are automatically wrapped.

MailTransaction.send(callback)

Connect to the server, transmit the message, and quit. The callback should be in the form function(err, message) { ... }. Upon success, err is null and message is set to the Message object that was sent to the server.

Compatibility

Node Mail has been tested against qmail and gmail using Node version v0.4.3. A working subset of these RFCs are supported:

There is not currently direct support for multipart messages or attachments, although node-mail will send messages in this format if they're build manually.

License

Copyright (c) 2010 - 2011, Ben Weaver <[email protected]> All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

More Repositories

1

moniker

Random name generator for Node.js
JavaScript
204
star
2

ReParse

ReParse is a parser combinator library for Javascript like Haskell's Parsec.
JavaScript
36
star
3

node-kyoto

Kyoto Cabinet bindings for Node.JS
C++
23
star
4

rewind

Automatically reload a node application when files change.
JavaScript
13
star
5

uuidjs

libuuid bindings for Node.JS
C++
7
star
6

keyboard.js

friendly, cross-browser keyboard support
JavaScript
6
star
7

begin.js

A control construct for callback-style asynchronous Javascript.
JavaScript
6
star
8

DefineJS

An AMD wrapper for Node modules
JavaScript
6
star
9

Toji

Kyoto Cabinet bindings for Node.js with an Avro mapper.
JavaScript
6
star
10

sic

Scheme Incremental Compiler
Scheme
4
star
11

jquery-value

Adds .value(), an extensible version of .val()
JavaScript
3
star
12

scribbles

Nothing in particular
JavaScript
3
star
13

node-text

A collection of utilities for manipulating text in Node.JS
JavaScript
3
star
14

jquery.transform-ui

A jQuery UI widget for jquery.transform
JavaScript
3
star
15

nodebot

An IRC bot implemented in Node.js
JavaScript
2
star
16

literate.js

Generate documents from Javascript source written in a literate style.
JavaScript
2
star
17

hello-clojure

Learn Clojure by example.
Clojure
1
star
18

node-base64

Base64 encoding and decoding for Node.JS
JavaScript
1
star
19

sicp-61a

Homework for Brian Harvey's CS61A Volume 1
Scheme
1
star
20

View.js

A system for defining javascript UI glue for roles.
JavaScript
1
star
21

setup.js

Manage library folders and external dependency folders in your project by including setup.js.
JavaScript
1
star
22

node-chrome-host

Use the Chrome Extension API through a Node web service.
JavaScript
1
star