nodemailer 6.7.3 → 6.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.gitattributes ADDED
@@ -0,0 +1,6 @@
1
+ *.js text eol=lf
2
+ *.txt text eol=lf
3
+ *.html text eol=lf
4
+ *.htm text eol=lf
5
+ *.ics -text
6
+ *.bin -text
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 6.7.5 2022-05-04
4
+
5
+ - No changes, pushing a new README to npmjs.org
6
+
7
+ ## 6.7.4 2022-04-29
8
+
9
+ - Ensure compatibility with Node 18
10
+ - Replaced Travis with Github Actions
11
+
3
12
  ## 6.7.3 2022-03-21
4
13
 
5
14
  - Typo fixes
package/README.md CHANGED
@@ -8,9 +8,15 @@ Send emails from Node.js – easy as cake! 🍰✉️
8
8
 
9
9
  See [nodemailer.com](https://nodemailer.com/) for documentation and terms.
10
10
 
11
- ## Having an issue?
11
+ ---
12
+
13
+ > Check out **[EmailEngine](https://emailengine.app/?utm_source=github-nodemailer&utm_campaign=nodemailer&utm_medium=readme-link)** – a self-hosted email gateway that allows making **REST requests against IMAP and SMTP servers**. EmailEngine also sends webhooks whenever something changes on the registered accounts.\
14
+ > \
15
+ > Using the email accounts registered with EmailEngine, you can receive and [send emails](https://emailengine.app/sending-emails?utm_source=github-nodemailer&utm_campaign=nodemailer&utm_medium=readme-link). EmailEngine supports OAuth2, delayed sends, opens and clicks tracking, bounce detection, etc. All on top of regular email accounts without an external MTA service.
16
+
17
+ ---
12
18
 
13
- > Nodemailer supports all Node.js versions starting from Node.js@v6.0.0. The existing test suite does not support such old Node.js versions, so all features are not tested. From time to time, some regression bugs might occur because of this.
19
+ ## Having an issue?
14
20
 
15
21
  #### First review the docs
16
22
 
@@ -18,7 +24,7 @@ Documentation for Nodemailer can be found at [nodemailer.com](https://nodemailer
18
24
 
19
25
  #### Nodemailer throws a SyntaxError for "..."
20
26
 
21
- You are using an older Node.js version than v6.0. Upgrade Node.js to get support for the spread operator.
27
+ You are using an older Node.js version than v6.0. Upgrade Node.js to get support for the spread operator. Nodemailer supports all Node.js versions starting from Node.js@v6.0.0.
22
28
 
23
29
  #### I'm having issues with Gmail
24
30
 
@@ -35,13 +41,24 @@ It's either a firewall issue, or your SMTP server blocks authentication attempts
35
41
  #### I get TLS errors
36
42
 
37
43
  - If you are running the code on your machine, check your antivirus settings. Antiviruses often mess around with email ports usage. Node.js might not recognize the MITM cert your antivirus is using.
38
- - Latest Node versions allow only TLS versions 1.2 and higher. Some servers might still use TLS 1.1 or lower. Check Node.js docs on how to get correct TLS support for your app.
39
- - You might have the wrong value for the `secure` option. This is `true` _only_ for port 465. For every other port, it should be `false`. Setting `secure` to `false` does not mean that Nodemailer would not use TLS. Nodemailer would still try to upgrade the connection to use TLS if the server supports it.
40
- - Older Node versions do not support the newest Let's Encrypt certificates. Either set `tls.rejectUnauthorized` to `false` or upgrade your Node version
44
+ - Latest Node versions allow only TLS versions 1.2 and higher. Some servers might still use TLS 1.1 or lower. Check Node.js docs on how to get correct TLS support for your app. You can change this with [tls.minVersion](https://nodejs.org/dist/latest-v16.x/docs/api/tls.html#tls_tls_createsecurecontext_options) option
45
+ - You might have the wrong value for the `secure` option. This should be set to `true` only for port 465. For every other port, it should be `false`. Setting it to `false` does not mean that Nodemailer would not use TLS. Nodemailer would still try to upgrade the connection to use TLS if the server supports it.
46
+ - Older Node versions do not fully support the certificate chain of the newest Let's Encrypt certificates. Either set [tls.rejectUnauthorized](https://nodejs.org/dist/latest-v16.x/docs/api/tls.html#tlsconnectoptions-callback) to `false` to skip chain verification or upgrade your Node version
47
+
48
+ ```
49
+ let configOptions = {
50
+ host: "smtp.example.com",
51
+ port: 587,
52
+ tls: {
53
+ rejectUnauthorized: true,
54
+ minVersion: "TLSv1.2"
55
+ }
56
+ }
57
+ ```
41
58
 
42
59
  #### I have issues with DNS / hosts file
43
60
 
44
- Nodemailer uses `dns.resolve4()` and `dns.resolve6()` to resolve hostname into an IP address. If both calls fail, then Nodemailer will fall back to `dns.lookup()`. If this does not work for you, you can hard code the IP address into the configuration. In that case, Nodemailer would not perform any DNS lookups.
61
+ Node.js uses [c-ares](https://nodejs.org/en/docs/meta/topics/dependencies/#c-ares) to resolve domain names, not the DNS library provided by the system, so if you have some custom DNS routing set up, it might be ignored. Nodemailer runs [dns.resolve4()](https://nodejs.org/dist/latest-v16.x/docs/api/dns.html#dnsresolve4hostname-options-callback) and [dns.resolve6()](https://nodejs.org/dist/latest-v16.x/docs/api/dns.html#dnsresolve6hostname-options-callback) to resolve hostname into an IP address. If both calls fail, then Nodemailer will fall back to [dns.lookup()](https://nodejs.org/dist/latest-v16.x/docs/api/dns.html#dnslookuphostname-options-callback). If this does not work for you, you can hard code the IP address into the configuration like shown below. In that case, Nodemailer would not perform any DNS lookups.
45
62
 
46
63
  ```
47
64
  let configOptions = {
@@ -55,6 +72,10 @@ let configOptions = {
55
72
  }
56
73
  ```
57
74
 
75
+ #### I have an issue with TypeScript types
76
+
77
+ Nodemailer has official support for Node.js only. For anything related to TypeScript, you need to directly contact the authors of the [type definitions](https://www.npmjs.com/package/@types/nodemailer).
78
+
58
79
  #### I have a different problem
59
80
 
60
81
  If you are having issues with Nodemailer, then the best way to find help would be [Stack Overflow](https://stackoverflow.com/search?q=nodemailer) or revisit the [docs](https://nodemailer.com/about/).
@@ -51,7 +51,7 @@ function wrap(str, lineLength) {
51
51
  *
52
52
  * @constructor
53
53
  * @param {Object} options Stream options
54
- * @param {Number} [options.lineLength=76] Maximum lenght for lines, set to false to disable wrapping
54
+ * @param {Number} [options.lineLength=76] Maximum length for lines, set to false to disable wrapping
55
55
  */
56
56
  class Encoder extends Transform {
57
57
  constructor(options) {
package/lib/dkim/index.js CHANGED
@@ -54,10 +54,10 @@ class DKIMSigner {
54
54
  this.output = output;
55
55
  this.output.usingCache = false;
56
56
 
57
- this.errored = false;
57
+ this.hasErrored = false;
58
58
 
59
59
  this.input.on('error', err => {
60
- this.errored = true;
60
+ this.hasErrored = true;
61
61
  this.cleanup();
62
62
  output.emit('error', err);
63
63
  });
@@ -84,7 +84,7 @@ class DKIMSigner {
84
84
  }
85
85
 
86
86
  sendNextChunk() {
87
- if (this.errored) {
87
+ if (this.hasErrored) {
88
88
  return;
89
89
  }
90
90
 
@@ -145,7 +145,7 @@ class DKIMSigner {
145
145
  // do nothing
146
146
  }
147
147
  });
148
- this.errored = true;
148
+ this.hasErrored = true;
149
149
  // emit error
150
150
  this.output.emit('error', err);
151
151
  });
@@ -11,12 +11,12 @@ const packageData = require('../../package.json');
11
11
  const MAX_REDIRECTS = 5;
12
12
 
13
13
  module.exports = function (url, options) {
14
- return fetch(url, options);
14
+ return nmfetch(url, options);
15
15
  };
16
16
 
17
17
  module.exports.Cookies = Cookies;
18
18
 
19
- function fetch(url, options) {
19
+ function nmfetch(url, options) {
20
20
  options = options || {};
21
21
 
22
22
  options.fetchRes = options.fetchRes || new PassThrough();
@@ -202,7 +202,7 @@ function fetch(url, options) {
202
202
  // redirect does not include POST body
203
203
  options.method = 'GET';
204
204
  options.body = false;
205
- return fetch(urllib.resolve(url, res.headers.location), options);
205
+ return nmfetch(urllib.resolve(url, res.headers.location), options);
206
206
  }
207
207
 
208
208
  fetchRes.statusCode = res.statusCode;
@@ -532,7 +532,7 @@ const mimeTypes = new Map([
532
532
  ['application/x-bittorrent', 'torrent'],
533
533
  ['application/x-bsh', ['bsh', 'sh', 'shar']],
534
534
  ['application/x-bytecode.elisp', 'elc'],
535
- ['applicaiton/x-bytecode.python', 'pyc'],
535
+ ['application/x-bytecode.python', 'pyc'],
536
536
  ['application/x-bzip', 'bz'],
537
537
  ['application/x-bzip2', ['boz', 'bz2']],
538
538
  ['application/x-cdf', 'cdf'],
@@ -1688,7 +1688,7 @@ const extensions = new Map([
1688
1688
  ['pwz', 'application/vnd.ms-powerpoint'],
1689
1689
  ['py', 'text/x-script.phyton'],
1690
1690
  ['pya', 'audio/vnd.ms-playready.media.pya'],
1691
- ['pyc', 'applicaiton/x-bytecode.python'],
1691
+ ['pyc', 'application/x-bytecode.python'],
1692
1692
  ['pyv', 'video/vnd.ms-playready.media.pyv'],
1693
1693
  ['qam', 'application/vnd.epson.quickanime'],
1694
1694
  ['qbo', 'application/vnd.intu.qbo'],
@@ -13,7 +13,7 @@ const mimeFuncs = require('../mime-funcs');
13
13
  const qp = require('../qp');
14
14
  const base64 = require('../base64');
15
15
  const addressparser = require('../addressparser');
16
- const fetch = require('../fetch');
16
+ const nmfetch = require('../fetch');
17
17
  const LastNewline = require('./last-newline');
18
18
 
19
19
  const LeWindows = require('./le-windows');
@@ -971,7 +971,7 @@ class MimeNode {
971
971
  return contentStream;
972
972
  }
973
973
  // fetch URL
974
- return fetch(content.href, { headers: content.httpHeaders });
974
+ return nmfetch(content.href, { headers: content.httpHeaders });
975
975
  } else {
976
976
  // pass string or buffer content as a stream
977
977
  contentStream = new PassThrough();
package/lib/nodemailer.js CHANGED
@@ -8,7 +8,7 @@ const SendmailTransport = require('./sendmail-transport');
8
8
  const StreamTransport = require('./stream-transport');
9
9
  const JSONTransport = require('./json-transport');
10
10
  const SESTransport = require('./ses-transport');
11
- const fetch = require('./fetch');
11
+ const nmfetch = require('./fetch');
12
12
  const packageData = require('../package.json');
13
13
 
14
14
  const ETHEREAL_API = (process.env.ETHEREAL_API || 'https://api.nodemailer.com').replace(/\/+$/, '');
@@ -79,7 +79,7 @@ module.exports.createTestAccount = function (apiUrl, callback) {
79
79
  let chunks = [];
80
80
  let chunklen = 0;
81
81
 
82
- let req = fetch(apiUrl + '/user', {
82
+ let req = nmfetch(apiUrl + '/user', {
83
83
  contentType: 'application/json',
84
84
  method: 'POST',
85
85
  body: Buffer.from(
@@ -5,7 +5,7 @@
5
5
  const urllib = require('url');
6
6
  const util = require('util');
7
7
  const fs = require('fs');
8
- const fetch = require('../fetch');
8
+ const nmfetch = require('../fetch');
9
9
  const dns = require('dns');
10
10
  const net = require('net');
11
11
  const os = require('os');
@@ -14,7 +14,7 @@ const DNS_TTL = 5 * 60 * 1000;
14
14
 
15
15
  const networkInterfaces = (module.exports.networkInterfaces = os.networkInterfaces());
16
16
 
17
- const resolver = (family, hostname, callback) => {
17
+ const isFamilySupported = family => {
18
18
  const familySupported =
19
19
  // crux that replaces Object.values(networkInterfaces) as Object.values is not supported in nodejs v6
20
20
  Object.keys(networkInterfaces)
@@ -22,7 +22,13 @@ const resolver = (family, hostname, callback) => {
22
22
  // crux that replaces .flat() as it is not supported in older Node versions (v10 and older)
23
23
  .reduce((acc, val) => acc.concat(val), [])
24
24
  .filter(i => !i.internal)
25
- .filter(i => i.family === 'IPv' + family).length > 0;
25
+ .filter(i => i.family === 'IPv' + family || i.family === family).length > 0;
26
+
27
+ return familySupported;
28
+ };
29
+
30
+ const resolver = (family, hostname, callback) => {
31
+ const familySupported = isFamilySupported(family);
26
32
 
27
33
  if (!familySupported) {
28
34
  return callback(null, []);
@@ -88,9 +94,9 @@ module.exports.resolveHostname = (options, callback) => {
88
94
  }
89
95
 
90
96
  let cached;
91
-
92
97
  if (dnsCache.has(options.host)) {
93
98
  cached = dnsCache.get(options.host);
99
+
94
100
  if (!cached.expires || cached.expires >= Date.now()) {
95
101
  return callback(
96
102
  null,
@@ -124,7 +130,7 @@ module.exports.resolveHostname = (options, callback) => {
124
130
 
125
131
  dnsCache.set(options.host, {
126
132
  value,
127
- expires: Date.now() + DNS_TTL
133
+ expires: Date.now() + (options.dnsTtl || DNS_TTL)
128
134
  });
129
135
 
130
136
  return callback(
@@ -158,7 +164,7 @@ module.exports.resolveHostname = (options, callback) => {
158
164
 
159
165
  dnsCache.set(options.host, {
160
166
  value,
161
- expires: Date.now() + DNS_TTL
167
+ expires: Date.now() + (options.dnsTtl || DNS_TTL)
162
168
  });
163
169
 
164
170
  return callback(
@@ -170,7 +176,7 @@ module.exports.resolveHostname = (options, callback) => {
170
176
  }
171
177
 
172
178
  try {
173
- dns.lookup(options.host, {}, (err, address) => {
179
+ dns.lookup(options.host, { all: true }, (err, addresses) => {
174
180
  if (err) {
175
181
  if (cached) {
176
182
  // ignore error, use expired value
@@ -185,6 +191,19 @@ module.exports.resolveHostname = (options, callback) => {
185
191
  return callback(err);
186
192
  }
187
193
 
194
+ let address = addresses
195
+ ? addresses
196
+ .filter(addr => isFamilySupported(addr.family))
197
+ .map(addr => addr.address)
198
+ .shift()
199
+ : false;
200
+
201
+ if (addresses && addresses.length && !address) {
202
+ // there are addresses but none can be used
203
+ let err = new Error(`Can not use IPv${addresses[0].family} addresses with current network`);
204
+ return callback(err);
205
+ }
206
+
188
207
  if (!address && cached) {
189
208
  // nothing was found, fallback to cached value
190
209
  return callback(
@@ -202,7 +221,7 @@ module.exports.resolveHostname = (options, callback) => {
202
221
 
203
222
  dnsCache.set(options.host, {
204
223
  value,
205
- expires: Date.now() + DNS_TTL
224
+ expires: Date.now() + (options.dnsTtl || DNS_TTL)
206
225
  });
207
226
 
208
227
  return callback(
@@ -433,7 +452,7 @@ module.exports.resolveContent = (data, key, callback) => {
433
452
  callback(null, value);
434
453
  });
435
454
  } else if (/^https?:\/\//i.test(content.path || content.href)) {
436
- contentStream = fetch(content.path || content.href);
455
+ contentStream = nmfetch(content.path || content.href);
437
456
  return resolveStream(contentStream, callback);
438
457
  } else if (/^data:/i.test(content.path || content.href)) {
439
458
  let parts = (content.path || content.href).match(/^data:((?:[^;]*;)*(?:[^,]*)),(.*)$/i);
@@ -627,6 +627,13 @@ class SMTPPool extends EventEmitter {
627
627
 
628
628
  finalize();
629
629
  });
630
+ } else if (!auth && connection.allowsAuth) {
631
+ let err = new Error('Authentication info was not provided');
632
+ err.code = 'NoAuth';
633
+
634
+ returned = true;
635
+ connection.close();
636
+ return callback(err);
630
637
  } else {
631
638
  finalize();
632
639
  }
@@ -384,6 +384,13 @@ class SMTPTransport extends EventEmitter {
384
384
 
385
385
  finalize();
386
386
  });
387
+ } else if (!authData && connection.allowsAuth) {
388
+ let err = new Error('Authentication info was not provided');
389
+ err.code = 'NoAuth';
390
+
391
+ returned = true;
392
+ connection.close();
393
+ return callback(err);
387
394
  } else {
388
395
  finalize();
389
396
  }
@@ -11,6 +11,12 @@
11
11
  "host": "smtp.aol.com",
12
12
  "port": 587
13
13
  },
14
+
15
+ "Bluewin": {
16
+ "host": "smtpauths.bluewin.ch",
17
+ "domains": ["bluewin.ch"],
18
+ "port": 465
19
+ },
14
20
 
15
21
  "DebugMail": {
16
22
  "host": "debugmail.io",
@@ -188,8 +194,8 @@
188
194
  },
189
195
 
190
196
  "SendCloud": {
191
- "host": "smtpcloud.sohu.com",
192
- "port": 25
197
+ "host": "smtp.sendcloud.net",
198
+ "port": 2525
193
199
  },
194
200
 
195
201
  "SendGrid": {
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const Stream = require('stream').Stream;
4
- const fetch = require('../fetch');
4
+ const nmfetch = require('../fetch');
5
5
  const crypto = require('crypto');
6
6
  const shared = require('../shared');
7
7
 
@@ -310,7 +310,7 @@ class XOAuth2 extends Stream {
310
310
  let chunks = [];
311
311
  let chunklen = 0;
312
312
 
313
- let req = fetch(url, {
313
+ let req = nmfetch(url, {
314
314
  method: 'post',
315
315
  headers: params.customHeaders,
316
316
  body: payload,
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "nodemailer",
3
- "version": "6.7.3",
3
+ "version": "6.7.6",
4
4
  "description": "Easy as cake e-mail sending from your Node.js applications",
5
5
  "main": "lib/nodemailer.js",
6
6
  "scripts": {
7
- "test": "grunt"
7
+ "test": "grunt --trace-warnings"
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
@@ -20,25 +20,25 @@
20
20
  },
21
21
  "homepage": "https://nodemailer.com/",
22
22
  "devDependencies": {
23
- "@aws-sdk/client-ses": "3.54.1",
24
- "aws-sdk": "2.1096.0",
23
+ "@aws-sdk/client-ses": "3.118.1",
24
+ "aws-sdk": "2.1165.0",
25
25
  "bunyan": "1.8.15",
26
26
  "chai": "4.3.6",
27
27
  "eslint-config-nodemailer": "1.2.0",
28
28
  "eslint-config-prettier": "8.5.0",
29
- "grunt": "1.4.1",
29
+ "grunt": "1.5.3",
30
30
  "grunt-cli": "1.4.3",
31
31
  "grunt-eslint": "24.0.0",
32
32
  "grunt-mocha-test": "0.13.3",
33
33
  "libbase64": "1.2.1",
34
- "libmime": "5.0.0",
34
+ "libmime": "5.1.0",
35
35
  "libqp": "1.1.0",
36
- "mocha": "9.2.2",
36
+ "mocha": "10.0.0",
37
37
  "nodemailer-ntlm-auth": "1.0.1",
38
38
  "proxy": "1.0.2",
39
39
  "proxy-test-server": "1.0.0",
40
- "sinon": "13.0.1",
41
- "smtp-server": "3.10.0"
40
+ "sinon": "14.0.0",
41
+ "smtp-server": "3.11.0"
42
42
  },
43
43
  "engines": {
44
44
  "node": ">=6.0.0"