1 | [![npm][npm-image]][npm-url]
|
2 | [![downloads][downloads-image]][downloads-url]
|
3 | [![npm-issues][npm-issues-image]][npm-issues-url]
|
4 | [![js-standard-style][standard-image]][standard-url]
|
5 |
|
6 | [standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
|
7 | [standard-url]: http://standardjs.com/
|
8 | [npm-image]: https://img.shields.io/npm/v/sendmail.svg?style=flat
|
9 | [npm-url]: https://npmjs.org/package/sendmail
|
10 | [downloads-image]: https://img.shields.io/npm/dt/sendmail.svg?style=flat
|
11 | [downloads-url]: https://npmjs.org/package/sendmail
|
12 | [npm-issues-image]: https://img.shields.io/github/issues/guileen/node-sendmail.svg
|
13 | [npm-issues-url]: https://github.com/guileen/node-sendmail/issues
|
14 | # node-sendmail
|
15 |
|
16 | Send mail without SMTP server
|
17 |
|
18 | If you're interested in helping out this repo, please check out the roadmap below to see if anything interests you
|
19 |
|
20 | ## Roadmap
|
21 |
|
22 | * Add Testing
|
23 | * Add Better Error Handling
|
24 | * Add A Retry feature
|
25 | * Update how we do options
|
26 | * Respond with documented status codes
|
27 | * CRLF
|
28 | * replyTo
|
29 | * returnTo
|
30 | * Please submit your ideas as PR's
|
31 |
|
32 | ## Install
|
33 |
|
34 | ``` bash
|
35 | npm install sendmail --save
|
36 | # or
|
37 | yarn add sendmail
|
38 | ```
|
39 |
|
40 | ## Options
|
41 |
|
42 | ``` javascript
|
43 | const sendmail = require('sendmail')({
|
44 | logger: {
|
45 | debug: console.log,
|
46 | info: console.info,
|
47 | warn: console.warn,
|
48 | error: console.error
|
49 | },
|
50 | silent: false,
|
51 | dkim: { // Default: False
|
52 | privateKey: fs.readFileSync('./dkim-private.pem', 'utf8'),
|
53 | keySelector: 'mydomainkey'
|
54 | },
|
55 | devPort: 1025, // Default: False
|
56 | devHost: 'localhost', // Default: localhost
|
57 | smtpPort: 2525, // Default: 25
|
58 | smtpHost: 'localhost' // Default: -1 - extra smtp host after resolveMX
|
59 | })
|
60 | ```
|
61 |
|
62 | ## Usage
|
63 |
|
64 | ``` javascript
|
65 | const sendmail = require('sendmail')();
|
66 |
|
67 | sendmail({
|
68 | from: 'no-reply@yourdomain.com',
|
69 | to: 'test@qq.com, test@sohu.com, test@163.com ',
|
70 | subject: 'test sendmail',
|
71 | html: 'Mail of test sendmail ',
|
72 | }, function(err, reply) {
|
73 | console.log(err && err.stack);
|
74 | console.dir(reply);
|
75 | });
|
76 | ```
|
77 |
|
78 | ## Examples
|
79 |
|
80 | Please checkout our great examples
|
81 |
|
82 | - **[attachmentFile.js](https://github.com/guileen/node-sendmail/blob/master/examples/attachmentFile.js)**
|
83 | - **[developmentMode.js](https://github.com/guileen/node-sendmail/blob/master/examples/developmentMode.js)**
|
84 | - **[dkim.js](https://github.com/guileen/node-sendmail/blob/master/examples/dkim.js)**
|
85 | - **[meetingRequest.js](https://github.com/guileen/node-sendmail/blob/master/examples/meetingRequest.js)**
|
86 | - **[simple.js](https://github.com/guileen/node-sendmail/blob/master/examples/simple.js)**
|
87 | - **[devHostPort.js](https://github.com/guileen/node-sendmail/blob/master/examples/devHostPort.js)**
|
88 | - **[smtpPort.js](https://github.com/guileen/node-sendmail/blob/master/examples/smtpPort.js)**
|
89 |
|
90 | ## Upgrading
|
91 |
|
92 | Note if you were on any previous version before `<1.0.0` You will need to start using `html` instead of `content`. Instead of creating emails ourselves anymore we have decided to use `mailcomposer` to compose our emails. Which means we can give you the same great package with the best mail composer package out there.
|
93 |
|
94 | In 1.2.0 "Converted to ES2015" which will break node 4.x
|
95 |
|
96 | ## Mail Options
|
97 |
|
98 | Note we use `mailcomposer` to compose our mail before we send it out so all mail options will be well documented [Here](https://github.com/nodemailer/mailcomposer). But for those who want something particular go ahead and search down below.
|
99 |
|
100 | ### E-mail message fields
|
101 |
|
102 | Below are a list of the most used options for email fields. Please read the entire list of options here [Here](https://github.com/nodemailer/mailcomposer#e-mail-message-fields):
|
103 |
|
104 | - **from**
|
105 | - **sender**
|
106 | - **to**
|
107 | - **cc**
|
108 | - **bcc**
|
109 | - **replyTo**
|
110 | - **inReplyTo**
|
111 | - **subject**
|
112 | - **text**
|
113 | - **html**
|
114 |
|
115 | ### Attachments
|
116 |
|
117 | You are also able to send attachents. Please review the list of properties here [Here](https://github.com/nodemailer/mailcomposer#attachments)
|
118 |
|
119 | ### Alternatives
|
120 |
|
121 | In addition to text and HTML, any kind of data can be inserted as an alternative content of the main body. Please check that out [Here](https://github.com/nodemailer/mailcomposer#alternatives)
|
122 |
|
123 | ### Address Formatting
|
124 |
|
125 | All e-mail addresses can be formatted. Please check that out [Here](https://github.com/nodemailer/mailcomposer#address-formatting)
|
126 |
|
127 | ### SMTP envelope
|
128 |
|
129 | SMTP envelope is usually auto generated from `from`, `to`, `cc` and `bcc` fields but you can change them [Here](https://github.com/nodemailer/mailcomposer#smtp-envelope)
|
130 |
|
131 | ### Using Embedded Images
|
132 |
|
133 | Attachments can be used as embedded images in the HTML body. To use this feature, you need to set additional properties [Here](https://github.com/nodemailer/mailcomposer#using-embedded-images)
|
134 |
|
135 | ## Change Log
|
136 |
|
137 | ### 1.0.0 Mail Composer
|
138 |
|
139 | * A better way to compose the emails while still sending them out in the exact same way.
|
140 |
|
141 | ### 1.1.0 Support for development SMTP
|
142 |
|
143 | * A property describing a port for a local SMTP server (see [MailHog](https://github.com/mailhog/MailHog)) was added. If the property is omitted, sendmail behaves like it used to. This feature makes it possible to test an application offline and for multiple email addresses without needing to create hundreds of mail accounts. - Special thanks goes out to gumannp for [PR 21](https://github.com/guileen/node-sendmail/pull/21)
|
144 |
|
145 | ### 1.1.0 Add DKIM signing
|
146 |
|
147 | * Added a `dkim` object to options that can have two properties: `privateKey` and `keySelector`. These options correspond to the options for [`dkim-signer`](https://github.com/andris9/dkim-signer). Added an example for these options. Special thanks goes out to download13 for [PR 23](https://github.com/guileen/node-sendmail/pull/23)
|
148 |
|
149 | ### 1.1.1 Readme fix
|
150 |
|
151 | * simple link and text updates
|
152 |
|
153 | ### 1.2.0 Added Support for devHost & devPort
|
154 |
|
155 | * Add option to override "localhost" when sending all SMTP traffic to a dummy server & "Converted to ES2015"
|
156 |
|
157 | ### 1.3.0
|
158 |
|
159 | * Add option to override "smtpPort:25"
|
160 |
|
161 | ### 1.4.0
|
162 |
|
163 | * Add option to add extra smtp host after resolveMX "smtpHost:-1"
|
164 | * Added Yarn Lock
|
165 |
|
166 | ### 1.4.1
|
167 |
|
168 | * Update Readme
|
169 |
|
170 | ### 1.5.0
|
171 |
|
172 | * Update Readme - Special thanks goes out to zzzgit for [PR 58](https://github.com/guileen/node-sendmail/pull/58)
|
173 | * sort mx records by priority (lowest first) - Special thanks goes out to seasick for [PR 57](https://github.com/guileen/node-sendmail/pull/57)
|
174 |
|
175 | ### 1.6.0
|
176 |
|
177 | * Updated parsing to use auto parse
|
178 |
|
179 | ### 1.6.1
|
180 |
|
181 | * Rollback of autoparse
|
182 |
|
183 | ## Questions, Comments & Concerns
|
184 |
|
185 | Please reach out to [Green Pioneer](https://github.com/greenpioneer). If I dont respond the first time please feel free to reach out again to get help( Also try using @greenpioneer in issues or prs). [Guileen](https://github.com/guileen) is the original creator.
|