Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 127 lines (92 sloc) 4.49 kB
7304d3a @weaver Initial commit.
authored
1 # Node Mail #
2
3 This SMTP client helps you send email safely and easily using
db7b3ce @weaver v0.2.1 works with Node 0.4.3
authored
4 Node.JS. It supports TLS and auth-login so you can send through
5 gmail. It also implements sanity checks to safeguard against header
6 injection attacks.
7304d3a @weaver Initial commit.
authored
7
8 ## Installation ##
9
db7b3ce @weaver v0.2.1 works with Node 0.4.3
authored
10 Use NPM to install:
11
12 npm install mail
7304d3a @weaver Initial commit.
authored
13
14 ## Sending Mail ##
15
16 The `Mail` class encapsulates connection settings and can be used as a
17 safe, high-level mailer.
18
db7b3ce @weaver v0.2.1 works with Node 0.4.3
authored
19 var mail = require('mail').Mail({
d4a0e5d @weaver Tweak README.
authored
20 host: 'smtp.gmail.com',
21 username: 'me@gmail.com',
22 password: '**password**'
23 });
7304d3a @weaver Initial commit.
authored
24
db7b3ce @weaver v0.2.1 works with Node 0.4.3
authored
25 Use the mailer to send messages:
26
7304d3a @weaver Initial commit.
authored
27 mail.message({
d4a0e5d @weaver Tweak README.
authored
28 from: 'sender@example.net',
29 to: ['recipient@somewhere.org'],
30 subject: 'Hello from Node.JS'
31 })
32 .body('Node speaks SMTP!')
33 .send(function(err) {
34 if (err) throw err;
35 console.log('Sent!');
36 });
7304d3a @weaver Initial commit.
authored
37
db7b3ce @weaver v0.2.1 works with Node 0.4.3
authored
38 ## Mail(options) ##
7304d3a @weaver Initial commit.
authored
39
6816253 @weaver v0.2.2: support 8-bit mime transport
authored
40 Create a new mailer that can be used to send messages. Common options
41 include:
7304d3a @weaver Initial commit.
authored
42
43 + `host`: server hostname
44 + `username`: user for server authentication
6816253 @weaver v0.2.2: support 8-bit mime transport
authored
45 + `password`: password for server authentication,
46
47 Other options:
48
49 + `secure`: `true`, `false`, or crypto credentials (default: `true`)
d4a0e5d @weaver Tweak README.
authored
50 + `port`: server listens on this port (default: 587 or 25)
6816253 @weaver v0.2.2: support 8-bit mime transport
authored
51 + `domain`: the domain of the sender (default: `os.hostname()`)
52 + `mimeTransport`: `7BIT` or `8BITMIME` (default: `8BITMIME`)
7304d3a @weaver Initial commit.
authored
53
db7b3ce @weaver v0.2.1 works with Node 0.4.3
authored
54 ### Mail.message(headers) ###
7304d3a @weaver Initial commit.
authored
55
56 Begin a `MailTransaction`. The `headers` object may contain any any
57 SMTP headers. When the message is formatted, email addresses are
58 validated, header names are title-cased, and header values escaped to
59 prevent injection. A `Date` header is automatically added.
60
61 An email address may be an array, a single address, or a string with
62 command-separated addresses. Individual addresses may be bare or in
63 the format `"Display Name" <name@example.net>`.
64
db7b3ce @weaver v0.2.1 works with Node 0.4.3
authored
65 ### MailTransaction.body(text) ###
7304d3a @weaver Initial commit.
authored
66
67 Add a body to a mail transaction. Long lines are automatically
68 wrapped.
69
db7b3ce @weaver v0.2.1 works with Node 0.4.3
authored
70 ### MailTransaction.send(callback) ###
7304d3a @weaver Initial commit.
authored
71
72 Connect to the server, transmit the message, and quit. The callback
73 should be in the form `function(err, message) { ... }`. Upon success,
74 `err` is `null` and `message` is set to the `Message` object that was
75 sent to the server.
76
77 ## Compatibility ##
78
6f1e1fb @weaver Add package.json
authored
79 Node Mail has been tested against [qmail][1] and [gmail][2] using Node
db7b3ce @weaver v0.2.1 works with Node 0.4.3
authored
80 version `v0.4.3`. A working subset of these RFCs are supported:
7304d3a @weaver Initial commit.
authored
81
82 + [Internet Message Format](http://tools.ietf.org/html/rfc5322)
83 + [Simple Mail Transfer Protocol](http://tools.ietf.org/html/rfc5321)
6816253 @weaver v0.2.2: support 8-bit mime transport
authored
84 + [Authentication Extension](http://tools.ietf.org/html/rfc2554)
7304d3a @weaver Initial commit.
authored
85 + [SMTP Transport Layer Security](http://tools.ietf.org/html/rfc3207)
6816253 @weaver v0.2.2: support 8-bit mime transport
authored
86 + [8-bit MIME Transport](http://tools.ietf.org/html/rfc6152)
7304d3a @weaver Initial commit.
authored
87
d4a0e5d @weaver Tweak README.
authored
88 There is not currently direct support for multipart messages or
89 attachments, although `node-mail` will send messages in this format if
90 they're build manually.
7304d3a @weaver Initial commit.
authored
91
92 [1]: http://qmail.org/top.html
93 [2]: http://mail.google.com/support/bin/answer.py?hl=en&answer=13287
94
95 ## License ##
96
db7b3ce @weaver v0.2.1 works with Node 0.4.3
authored
97 Copyright (c) 2010 - 2011, Ben Weaver &lt;ben@orangesoda.net&gt;
7304d3a @weaver Initial commit.
authored
98 All rights reserved.
99
100 Redistribution and use in source and binary forms, with or without
101 modification, are permitted provided that the following conditions are
102 met:
103
104 * Redistributions of source code must retain the above copyright
105 notice, this list of conditions and the following disclaimer.
106
107 * Redistributions in binary form must reproduce the above copyright
108 notice, this list of conditions and the following disclaimer in the
109 documentation and/or other materials provided with the distribution.
110
111 * Neither the name of the <organization> nor the names of its
112 contributors may be used to endorse or promote products derived from
113 this software without specific prior written permission.
114
115 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
116 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
117 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
118 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT
119 HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
120 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
121 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
122 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
123 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
124 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
125 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
126
Something went wrong with that request. Please try again.