├── .eslintrc ├── .gitignore ├── .npmignore ├── .travis.yml ├── CHANGELOG.md ├── Gruntfile.js ├── LICENSE ├── README.md ├── lib └── smtp-connection.js ├── package.json └── test └── smtp-connection-test.js /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "nodemailer" 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | examples 4 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .travis.yml 2 | test 3 | examples 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | sudo: false 3 | node_js: 4 | - 6 5 | notifications: 6 | email: 7 | - andris@kreata.ee 8 | webhooks: 9 | urls: 10 | - https://webhooks.gitter.im/e/0ed18fd9b3e529b3c2cc 11 | on_success: change # options: [always|never|change] default: always 12 | on_failure: always # options: [always|never|change] default: always 13 | on_start: false # default: false 14 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## v4.0.0 2017-02-15 4 | 5 | * Changed license from MIT to EUPL-v1.1 6 | * Removed NTLM support 7 | * In general this module is now just a wrapper around the SMTPConnection class in Nodemailer 8 | 9 | ## v3.1.0 2016-12-21 10 | 11 | * use setKeepAlive(true) on newly created sockets 12 | 13 | ## v3.0.1 2016-12-09 14 | 15 | * Fixed non-structured logging 16 | 17 | ## v3.0.0 2016-12-09 18 | 19 | * Use ES6 syntax 20 | * Updated logging to support structured output for real Bunyan logger instances 21 | 22 | ## v2.12.1 2016-10-10 23 | 24 | * Fixed invalid SIZE detection 25 | 26 | ## v2.12.0 2016-09-05 27 | 28 | * Updated dependencies 29 | 30 | ## v2.11.0 2016-08-04 31 | 32 | * Added new envelope option `size` to skip sending messages that are too large 33 | 34 | ## v2.10.0 2016-07-22 35 | 36 | * Added new option `opportunisticTLS` to allow continuing if STARTTLS failed 37 | 38 | ## v2.9.0 2016-07-13 39 | 40 | * Added `reset(cb)` method to call `RSET` command 41 | * Include failed recipients in the response error object 42 | 43 | ## v2.8.0 2016-07-07 44 | 45 | * Added full LMTP support. Set `lmtp` option to `true` to switch into LMTP mode 46 | * Updated default timeout values 47 | 48 | ## v2.7.0 2016-07-06 49 | 50 | * Use PIPELINING for multiple RCPT TO if available 51 | 52 | ## v2.6.0 2016-07-06 53 | 54 | * Added support for DSN 55 | * Added new option use8BitMime to indicate that the message might include non-ascii bytes 56 | * Added new info property rejectedErrors that includes errors for failed recipients 57 | * Updated errors to indicate where the error happened (SMTP command, API, CONN) 58 | 59 | ## v2.5.0 2016-05-11 60 | 61 | * Bumped dependencies 62 | 63 | ## v2.4.0 2016-04-24 64 | 65 | * Added experimental support for NTLM authentication 66 | 67 | ## v2.3.2 2016-04-11 68 | 69 | * Declare SMTPUTF8 usage if an address includes Unicode characters and the server indicates support for it. Fixes an issue with internationalized email addresses that were rejected by Gmail 70 | 71 | ## v2.3.1 2016-02-20 72 | 73 | * Fix broken requireTLS option 74 | 75 | ## v2.3.0 2016-02-17 76 | 77 | * Do not modify provided options object 78 | 79 | ## v2.2.6 2016-02-16 80 | 81 | * Added yet another socket.resume to fixed an issue with proxied sockets and TLS 82 | 83 | ## v2.2.5 2016-02-15 84 | 85 | * Fixed an issue with proxied sockets and TLS 86 | 87 | ## v2.2.4 2016-02-11 88 | 89 | * Catch errors that happen while creating a socket 90 | 91 | ## v2.2.3 2016-02-11 92 | 93 | * Fixed error code for STARTTLS errors 94 | 95 | ## v2.2.2 2016-02-09 96 | 97 | * Bumped nodemailer-shared 98 | 99 | ## v2.2.1 2016-02-09 100 | 101 | * Make sure socket is resumed once 'data' handler is set 102 | 103 | ## v2.2.0 2016-02-08 104 | 105 | * Added new option `secured` to indicate if socket provided by `connection` is already upgraded or not 106 | 107 | ## v2.1.0 2016-01-30 108 | 109 | * Added new option `connection` to provide an already connected plaintext socket. Useful when behind proxy. 110 | 111 | ## v2.0.1 2016-01-04 112 | 113 | * Bumped nodemailer-shared 114 | 115 | ## v2.0.0 2016-01-04 116 | 117 | * Locked dependency version 118 | 119 | ## v2.0.0-beta.5 2016-01-03 120 | 121 | * Fixed a bug where errors might been thrown before a handler was set 122 | 123 | ## v2.0.0-beta.3 2016-01-03 124 | 125 | * Use shared function to create the logger instance 126 | 127 | ## v2.0.0-beta.2 2016-01-03 128 | 129 | * Updated logging. Log information about transmitted message size in bytes 130 | 131 | ## v2.0.0-beta.1 2016-01-03 132 | 133 | * Re-added `debug` option. If set to true, then logs SMTP traffic, otherwise only transaction events 134 | * Pass streamed message content to the logger 135 | 136 | ## v2.0.0-beta.0 2016-01-02 137 | 138 | * Replaced jshint with eslint 139 | * Handle message stream errors 140 | * Use bunyan compatible logger interface instead of emitting 'log' events 141 | 142 | ## v1.3.8 2015-12-29 143 | 144 | * Do not use strict isEmail function, just check that there are no newlines in addresses. Fixes a regression with lax e-mail addresses. 145 | 146 | ## v1.3.7 2015-12-22 147 | 148 | * Fixed an issue with Node v0.10 where too many events were cleared 149 | 150 | ## v1.3.6 2015-12-19 151 | 152 | * Updated isemail configuration to only allow SMTP compatible e-mail addresses for the envelope (otherwise valid addresses might include symbols that don't play well with SMTP, eg. line folding inside quoted strings) 153 | 154 | ## v1.3.5 2015-12-19 155 | 156 | * Validate to and from address to be valid e-mail addresses 157 | 158 | ## v1.3.2 2015-12-16 159 | 160 | * Added missing 'close' and 'end' event handlers for a STARTTLS-upgraded socket 161 | 162 | ## v1.3.1 2015-06-30 163 | 164 | * Added partial support for LMTP protocol. Works only with single recipient (does not support multiple responses for DATA command) 165 | 166 | ## v1.2.0 2015-03-09 167 | 168 | * Connection object has a new property `secure` that indicates if the current connection is using a secure TLS socket or not 169 | * Fixed `requireTLS` where the connection was established insecurely if STARTTLS failed, now it returns an error as it should if STARTTLS fails 170 | 171 | ## v1.1.0 2014-11-11 172 | 173 | * Added additional constructor option `requireTLS` to ensure that the connection is upgraded before any credentials are passed to the server 174 | * Added additional constructor option `socket` to use an existing socket instead of creating new one (bantu) 175 | 176 | ## v1.0.2 2014-10-15 177 | 178 | * Removed CleartextStream.pair.encrypted error handler. Does not seem to be supported by Node v0.11 179 | 180 | ## v1.0.1 2014-10-15 181 | 182 | * Added 'error' handler for CleartextStream.pair.encrypted object when connecting to TLS. 183 | 184 | ## v1.0.0 2014-09-26 185 | 186 | * Changed version scheme from 0.x to 1.x. 187 | * Improved error handling for timeout on creating a connection. Caused issues with `once('error')` handler as an error might have been emitted twice 188 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = function (grunt) { 4 | 5 | // Project configuration. 6 | grunt.initConfig({ 7 | eslint: { 8 | all: ['lib/*.js', 'test/*.js', 'Gruntfile.js'] 9 | }, 10 | 11 | mochaTest: { 12 | all: { 13 | options: { 14 | reporter: 'spec' 15 | }, 16 | src: ['test/*-test.js'] 17 | } 18 | } 19 | }); 20 | 21 | // Load the plugin(s) 22 | grunt.loadNpmTasks('grunt-eslint'); 23 | grunt.loadNpmTasks('grunt-mocha-test'); 24 | 25 | // Tasks 26 | grunt.registerTask('default', ['eslint', 'mochaTest']); 27 | }; 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-2017 Andris Reinman 2 | 3 | European Union Public Licence 4 | V. 1.1 5 | 6 | EUPL (c) the European Community 2007 7 | 8 | 9 | This European Union Public Licence (the "EUPL") applies to the Work or Software 10 | (as defined below) which is provided under the terms of this Licence. Any use 11 | of the Work, other than as authorised under this Licence is prohibited (to the 12 | extent such use is covered by a right of the copyright holder of the Work). 13 | 14 | The Original Work is provided under the terms of this Licence when the Licensor 15 | (as defined below) has placed the following notice immediately following the 16 | copyright notice for the Original Work: 17 | 18 | Licensed under the EUPL V.1.1 19 | 20 | or has expressed by any other mean his willingness to license under the EUPL. 21 | 22 | 23 | 1. Definitions 24 | 25 | In this Licence, the following terms have the following meaning: 26 | 27 | * The Licence: this Licence. 28 | 29 | * The Original Work or the Software: the software distributed and/or 30 | communicated by the Licensor under this Licence, available as Source Code 31 | and also as Executable Code as the case may be. 32 | 33 | * Derivative Works: the works or software that could be created by the 34 | Licensee, based upon the Original Work or modifications thereof. This 35 | Licence does not define the extent of modification or dependence on the 36 | Original Work required in order to classify a work as a Derivative Work; 37 | this extent is determined by copyright law applicable in the country 38 | mentioned in Article 15. 39 | 40 | * The Work: the Original Work and/or its Derivative Works. 41 | 42 | * The Source Code: the human-readable form of the Work which is the most 43 | convenient for people to study and modify. 44 | 45 | * The Executable Code: any code which has generally been compiled and which is 46 | meant to be interpreted by a computer as a program. 47 | 48 | * The Licensor: the natural or legal person that distributes and/or 49 | communicates the Work under the Licence. 50 | 51 | * Contributor(s): any natural or legal person who modifies the Work under the 52 | Licence, or otherwise contributes to the creation of a Derivative Work. 53 | 54 | * The Licensee or "You": any natural or legal person who makes any usage of 55 | the Software under the terms of the Licence. 56 | 57 | * Distribution and/or Communication: any act of selling, giving, lending, 58 | renting, distributing, communicating, transmitting, or otherwise making 59 | available, on-line or off-line, copies of the Work or providing access to 60 | its essential functionalities at the disposal of any other natural or legal 61 | person. 62 | 63 | 64 | 2. Scope of the rights granted by the Licence 65 | 66 | The Licensor hereby grants You a world-wide, royalty-free, non-exclusive, 67 | sublicensable licence to do the following, for the duration of copyright vested 68 | in the Original Work: 69 | 70 | * use the Work in any circumstance and for all usage, 71 | * reproduce the Work, 72 | * modify the Original Work, and make Derivative Works based upon the Work, 73 | * communicate to the public, including the right to make available or display 74 | the Work or copies thereof to the public and perform publicly, as the case 75 | may be, the Work, 76 | * distribute the Work or copies thereof, 77 | * lend and rent the Work or copies thereof, 78 | * sub-license rights in the Work or copies thereof. 79 | 80 | Those rights can be exercised on any media, supports and formats, whether now 81 | known or later invented, as far as the applicable law permits so. 82 | 83 | In the countries where moral rights apply, the Licensor waives his right to 84 | exercise his moral right to the extent allowed by law in order to make 85 | effective the licence of the economic rights here above listed. 86 | 87 | The Licensor grants to the Licensee royalty-free, non exclusive usage rights to 88 | any patents held by the Licensor, to the extent necessary to make use of the 89 | rights granted on the Work under this Licence. 90 | 91 | 92 | 3. Communication of the Source Code 93 | 94 | The Licensor may provide the Work either in its Source Code form, or as 95 | Executable Code. If the Work is provided as Executable Code, the Licensor 96 | provides in addition a machine-readable copy of the Source Code of the Work 97 | along with each copy of the Work that the Licensor distributes or indicates, in 98 | a notice following the copyright notice attached to the Work, a repository 99 | where the Source Code is easily and freely accessible for as long as the 100 | Licensor continues to distribute and/or communicate the Work. 101 | 102 | 103 | 4. Limitations on copyright 104 | 105 | Nothing in this Licence is intended to deprive the Licensee of the benefits 106 | from any exception or limitation to the exclusive rights of the rights owners 107 | in the Original Work or Software, of the exhaustion of those rights or of other 108 | applicable limitations thereto. 109 | 110 | 111 | 5. Obligations of the Licensee 112 | 113 | The grant of the rights mentioned above is subject to some restrictions and 114 | obligations imposed on the Licensee. Those obligations are the following: 115 | 116 | - Attribution right: the Licensee shall keep intact all copyright, patent or 117 | trademarks notices and all notices that refer to the Licence and to the 118 | disclaimer of warranties. The Licensee must include a copy of such notices 119 | and a copy of the Licence with every copy of the Work he/she distributes 120 | and/or communicates. The Licensee must cause any Derivative Work to carry 121 | prominent notices stating that the Work has been modified and the date of 122 | modification. 123 | 124 | - Copyleft clause: If the Licensee distributes and/or communicates copies of 125 | the Original Works or Derivative Works based upon the Original Work, this 126 | Distribution and/or Communication will be done under the terms of this 127 | Licence or of a later version of this Licence unless the Original Work is 128 | expressly distributed only under this version of the Licence. The Licensee 129 | (becoming Licensor) cannot offer or impose any additional terms or 130 | conditions on the Work or Derivative Work that alter or restrict the terms 131 | of the Licence. 132 | 133 | - Compatibility clause: If the Licensee Distributes and/or Communicates 134 | Derivative Works or copies thereof based upon both the Original Work and 135 | another work licensed under a Compatible Licence, this Distribution and/or 136 | Communication can be done under the terms of this Compatible Licence. For 137 | the sake of this clause, "Compatible Licence" refers to the licences listed 138 | in the appendix attached to this Licence. Should the Licensee's obligations 139 | under the Compatible Licence conflict with his/her obligations under this 140 | Licence, the obligations of the Compatible Licence shall prevail. 141 | 142 | - Provision of Source Code: When distributing and/or communicating copies of 143 | the Work, the Licensee will provide a machine-readable copy of the Source 144 | Code or indicate a repository where this Source will be easily and freely 145 | available for as long as the Licensee continues to distribute and/or 146 | communicate the Work. Legal Protection: This Licence does not grant 147 | permission to use the trade names, trademarks, service marks, or names of 148 | the Licensor, except as required for reasonable and customary use in 149 | describing the origin of the Work and reproducing the content of the 150 | copyright notice. 151 | 152 | 153 | 6. Chain of Authorship 154 | 155 | The original Licensor warrants that the copyright in the Original Work granted 156 | hereunder is owned by him/her or licensed to him/her and that he/she has the 157 | power and authority to grant the Licence. 158 | 159 | Each Contributor warrants that the copyright in the modifications he/she brings 160 | to the Work are owned by him/her or licensed to him/her and that he/she has the 161 | power and authority to grant the Licence. 162 | 163 | Each time You accept the Licence, the original Licensor and subsequent 164 | Contributors grant You a licence to their contributions to the Work, under the 165 | terms of this Licence. 166 | 167 | 168 | 7. Disclaimer of Warranty 169 | 170 | The Work is a work in progress, which is continuously improved by numerous 171 | contributors. It is not a finished work and may therefore contain defects or 172 | "bugs" inherent to this type of software development. 173 | 174 | For the above reason, the Work is provided under the Licence on an "as is" 175 | basis and without warranties of any kind concerning the Work, including without 176 | limitation merchantability, fitness for a particular purpose, absence of 177 | defects or errors, accuracy, non-infringement of intellectual property rights 178 | other than copyright as stated in Article 6 of this Licence. 179 | 180 | This disclaimer of warranty is an essential part of the Licence and a condition 181 | for the grant of any rights to the Work. 182 | 183 | 184 | 8. Disclaimer of Liability 185 | 186 | Except in the cases of wilful misconduct or damages directly caused to natural 187 | persons, the Licensor will in no event be liable for any direct or indirect, 188 | material or moral, damages of any kind, arising out of the Licence or of the 189 | use of the Work, including without limitation, damages for loss of goodwill, 190 | work stoppage, computer failure or malfunction, loss of data or any commercial 191 | damage, even if the Licensor has been advised of the possibility of such 192 | damage. However, the Licensor will be liable under statutory product liability 193 | laws as far such laws apply to the Work. 194 | 195 | 196 | 9. Additional agreements 197 | 198 | While distributing the Original Work or Derivative Works, You may choose to 199 | conclude an additional agreement to offer, and charge a fee for, acceptance of 200 | support, warranty, indemnity, or other liability obligations and/or services 201 | consistent with this Licence. However, in accepting such obligations, You may 202 | act only on your own behalf and on your sole responsibility, not on behalf of 203 | the original Licensor or any other Contributor, and only if You agree to 204 | indemnify, defend, and hold each Contributor harmless for any liability 205 | incurred by, or claims asserted against such Contributor by the fact You have 206 | accepted any such warranty or additional liability. 207 | 208 | 209 | 10. Acceptance of the Licence 210 | 211 | The provisions of this Licence can be accepted by clicking on an icon "I agree" 212 | placed under the bottom of a window displaying the text of this Licence or by 213 | affirming consent in any other similar way, in accordance with the rules of 214 | applicable law. Clicking on that icon indicates your clear and irrevocable 215 | acceptance of this Licence and all of its terms and conditions. 216 | 217 | Similarly, you irrevocably accept this Licence and all of its terms and 218 | conditions by exercising any rights granted to You by Article 2 of this 219 | Licence, such as the use of the Work, the creation by You of a Derivative Work 220 | or the Distribution and/or Communication by You of the Work or copies thereof. 221 | 222 | 223 | 11. Information to the public 224 | 225 | In case of any Distribution and/or Communication of the Work by means of 226 | electronic communication by You (for example, by offering to download the Work 227 | from a remote location) the distribution channel or media (for example, a 228 | website) must at least provide to the public the information requested by the 229 | applicable law regarding the Licensor, the Licence and the way it may be 230 | accessible, concluded, stored and reproduced by the Licensee. 231 | 232 | 233 | 12. Termination of the Licence 234 | 235 | The Licence and the rights granted hereunder will terminate automatically upon 236 | any breach by the Licensee of the terms of the Licence. 237 | 238 | Such a termination will not terminate the licences of any person who has 239 | received the Work from the Licensee under the Licence, provided such persons 240 | remain in full compliance with the Licence. 241 | 242 | 243 | 13. Miscellaneous 244 | 245 | Without prejudice of Article 9 above, the Licence represents the complete 246 | agreement between the Parties as to the Work licensed hereunder. 247 | 248 | If any provision of the Licence is invalid or unenforceable under applicable 249 | law, this will not affect the validity or enforceability of the Licence as a 250 | whole. Such provision will be construed and/or reformed so as necessary to make 251 | it valid and enforceable. 252 | 253 | The European Commission may publish other linguistic versions and/or new 254 | versions of this Licence, so far this is required and reasonable, without 255 | reducing the scope of the rights granted by the Licence. New versions of the 256 | Licence will be published with a unique version number. 257 | 258 | All linguistic versions of this Licence, approved by the European Commission, 259 | have identical value. Parties can take advantage of the linguistic version of 260 | their choice. 261 | 262 | 263 | 14. Jurisdiction 264 | 265 | Any litigation resulting from the interpretation of this License, arising 266 | between the European Commission, as a Licensor, and any Licensee, will be 267 | subject to the jurisdiction of the Court of Justice of the European 268 | Communities, as laid down in article 238 of the Treaty establishing the 269 | European Community. 270 | 271 | Any litigation arising between Parties, other than the European Commission, and 272 | resulting from the interpretation of this License, will be subject to the 273 | exclusive jurisdiction of the competent court where the Licensor resides or 274 | conducts its primary business. 275 | 276 | 277 | 15. Applicable Law 278 | 279 | This Licence shall be governed by the law of the European Union country where 280 | the Licensor resides or has his registered office. 281 | 282 | This licence shall be governed by the Belgian law if: 283 | 284 | * a litigation arises between the European Commission, as a Licensor, and any 285 | Licensee; 286 | * the Licensor, other than the European Commission, has no residence or 287 | registered office inside a European Union country. 288 | 289 | 290 | Appendix 291 | 292 | "Compatible Licences" according to article 5 EUPL are: 293 | 294 | * GNU General Public License (GNU GPL) v. 2 295 | * Open Software License (OSL) v. 2.1, v. 3.0 296 | * Common Public License v. 1.0 297 | * Eclipse Public License v. 1.0 298 | * Cecill v. 2.0 299 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # smtp-connection 2 | 3 | ![Nodemailer](https://raw.githubusercontent.com/nodemailer/nodemailer/master/assets/nm_logo_200x136.png) 4 | 5 | SMTP client module. Connect to SMTP servers and send mail with it. 6 | 7 | See [smtp-connection homepage](https://nodemailer.com/extras/smtp-connection/) for documentation and terms. 8 | -------------------------------------------------------------------------------- /lib/smtp-connection.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | // See the following for the actual source code: 4 | // https://github.com/nodemailer/nodemailer/blob/master/lib/smtp-connection/index.js 5 | 6 | const SMTPConnection = require('nodemailer/lib/smtp-connection'); 7 | 8 | module.exports = SMTPConnection; 9 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "smtp-connection", 3 | "version": "4.0.2", 4 | "description": "Connect to SMTP servers", 5 | "main": "lib/smtp-connection.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "scripts": { 10 | "test": "grunt mochaTest" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git://github.com/andris9/smtp-connection.git" 15 | }, 16 | "keywords": [ 17 | "SMTP" 18 | ], 19 | "author": "Andris Reinman", 20 | "license": "EUPL-1.1", 21 | "bugs": { 22 | "url": "https://github.com/andris9/smtp-connection/issues" 23 | }, 24 | "homepage": "https://github.com/andris9/smtp-connection", 25 | "devDependencies": { 26 | "bunyan": "^1.8.5", 27 | "chai": "^3.5.0", 28 | "eslint-config-nodemailer": "^1.0.0", 29 | "grunt": "^1.0.1", 30 | "grunt-cli": "^1.2.0", 31 | "grunt-eslint": "^19.0.0", 32 | "grunt-mocha-test": "^0.13.2", 33 | "mocha": "^3.2.0" 34 | }, 35 | "dependencies": { 36 | "nodemailer": "^3.1.1" 37 | }, 38 | "engines": { 39 | "node": ">=6.0.0" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /test/smtp-connection-test.js: -------------------------------------------------------------------------------- 1 | /* eslint no-unused-expressions:0, no-invalid-this:0, prefer-arrow-callback: 0 */ 2 | /* globals describe, it */ 3 | 4 | 'use strict'; 5 | 6 | // THis is just a wrapper, actual SMTPConnection tests reside here: 7 | // https://github.com/nodemailer/nodemailer/tree/master/test/smtp-connection 8 | 9 | const chai = require('chai'); 10 | const expect = chai.expect; 11 | const SMTPConnection = require('../lib/smtp-connection'); 12 | 13 | chai.config.includeStack = true; 14 | 15 | describe('Version test', function () { 16 | it('Should expose version number', function () { 17 | let client = new SMTPConnection(); 18 | expect(client.version).to.exist; 19 | }); 20 | }); 21 | --------------------------------------------------------------------------------