nodemailer 6.7.3 → 6.7.4

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,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 6.7.4 2022-04-29
4
+
5
+ - Ensure compatibility with Node 18
6
+ - Replaced Travis with Github Actions
7
+
3
8
  ## 6.7.3 2022-03-21
4
9
 
5
10
  - Typo fixes
package/README.md CHANGED
@@ -35,13 +35,24 @@ It's either a firewall issue, or your SMTP server blocks authentication attempts
35
35
  #### I get TLS errors
36
36
 
37
37
  - 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
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. You can change this with [tls.minVersion](https://nodejs.org/dist/latest-v16.x/docs/api/tls.html#tls_tls_createsecurecontext_options) option
39
+ - 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.
40
+ - 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
41
+
42
+ ```
43
+ let configOptions = {
44
+ host: "smtp.example.com",
45
+ port: 587,
46
+ tls: {
47
+ rejectUnauthorized: true,
48
+ minVersion: "TLSv1.2"
49
+ }
50
+ }
51
+ ```
41
52
 
42
53
  #### I have issues with DNS / hosts file
43
54
 
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.
55
+ 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
56
 
46
57
  ```
47
58
  let configOptions = {
@@ -55,6 +66,10 @@ let configOptions = {
55
66
  }
56
67
  ```
57
68
 
69
+ #### I have an issue with TypeScript types
70
+
71
+ 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).
72
+
58
73
  #### I have a different problem
59
74
 
60
75
  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/).
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;
@@ -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);
@@ -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.4",
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.79.0",
24
+ "aws-sdk": "2.1124.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.2",
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
36
  "mocha": "9.2.2",
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": "13.0.2",
41
+ "smtp-server": "3.11.0"
42
42
  },
43
43
  "engines": {
44
44
  "node": ">=6.0.0"