nodemailer 6.7.2 → 6.7.5

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,22 @@
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
+
12
+ ## 6.7.3 2022-03-21
13
+
14
+ - Typo fixes
15
+ - Added stale issue automation fir Github
16
+ - Add Infomaniak config to well known service (popod)
17
+ - Update Outlook/Hotmail host in well known services (popod)
18
+ - fix: DSN recipient gets ignored (KornKalle)
19
+
3
20
  ## 6.7.2 2021-11-26
4
21
 
5
22
  - Fix proxies for account verification
@@ -81,7 +98,7 @@
81
98
  ## 6.4.7 2020-05-28
82
99
 
83
100
  - Always set charset=utf-8 for Content-Type headers
84
- - Catch error whn using invalid crypto.sign input
101
+ - Catch error when using invalid crypto.sign input
85
102
 
86
103
  ## 6.4.6 2020-03-20
87
104
 
package/README.md CHANGED
@@ -2,15 +2,21 @@
2
2
 
3
3
  [![Nodemailer](https://raw.githubusercontent.com/nodemailer/nodemailer/master/assets/nm_logo_200x136.png)](https://nodemailer.com/about/)
4
4
 
5
- Send e-mails from Node.js – easy as cake! 🍰✉️
5
+ Send emails from Node.js – easy as cake! 🍰✉️
6
6
 
7
7
  [![NPM](https://nodei.co/npm/nodemailer.png?downloads=true&downloadRank=true&stars=true)](https://nodemailer.com/about/)
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. Existing test suite does not support such old Node.js versions so all features are not actually 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,20 +24,57 @@ 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 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
 
25
- Gmail either works well or it does not work at all. It is probably easier to switch to an alternative service instead of fixing issues with Gmail. If Gmail does not work for you then don't use it. Read more about it [here](https://nodemailer.com/usage/using-gmail/).
31
+ Gmail either works well, or it does not work at all. It is probably easier to switch to an alternative service instead of fixing issues with Gmail. If Gmail does not work for you, then don't use it. Read more about it [here](https://nodemailer.com/usage/using-gmail/).
26
32
 
27
33
  #### I get ETIMEDOUT errors
28
34
 
29
- Check your firewall settings. Timeout usually occurs when you try to open a connection to a port that is firewalled either on the server or on your machine.
35
+ Check your firewall settings. Timeout usually occurs when you try to open a connection to a firewalled port either on the server or on your machine. Some ISPs also block email ports to prevent spamming.
36
+
37
+ #### Nodemailer works on one machine but not in another
38
+
39
+ It's either a firewall issue, or your SMTP server blocks authentication attempts from some servers.
30
40
 
31
41
  #### I get TLS errors
32
42
 
33
- - If you are running the code in your own machine, then check your antivirus settings. Antiviruses often mess around with email ports usage. Node.js might not recognize the MITM cert your antivirus is using.
34
- - 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 how to get correct TLS support for your app.
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.
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
+ ```
58
+
59
+ #### I have issues with DNS / hosts file
60
+
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.
62
+
63
+ ```
64
+ let configOptions = {
65
+ host: "1.2.3.4",
66
+ port: 465,
67
+ secure: true,
68
+ tls: {
69
+ // must provide server name, otherwise TLS certificate check will fail
70
+ servername: "example.com"
71
+ }
72
+ }
73
+ ```
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).
35
78
 
36
79
  #### I have a different problem
37
80
 
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(
package/lib/qp/index.js CHANGED
@@ -149,7 +149,7 @@ function checkRanges(nr, ranges) {
149
149
  *
150
150
  * @constructor
151
151
  * @param {Object} options Stream options
152
- * @param {Number} [options.lineLength=76] Maximum lenght for lines, set to false to disable wrapping
152
+ * @param {Number} [options.lineLength=76] Maximum length for lines, set to false to disable wrapping
153
153
  */
154
154
  class Encoder extends Transform {
155
155
  constructor(options) {
@@ -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);
@@ -1108,7 +1108,7 @@ class SMTPConnection extends EventEmitter {
1108
1108
  notify = notify.join(',');
1109
1109
  }
1110
1110
 
1111
- let orcpt = (params.orcpt || params.recipient || '').toString() || null;
1111
+ let orcpt = (params.recipient || params.orcpt || '').toString() || null;
1112
1112
  if (orcpt && orcpt.indexOf(';') < 0) {
1113
1113
  orcpt = 'rfc822;' + orcpt;
1114
1114
  }
@@ -72,7 +72,7 @@
72
72
  "Hotmail": {
73
73
  "aliases": ["Outlook", "Outlook.com", "Hotmail.com"],
74
74
  "domains": ["hotmail.com", "outlook.com"],
75
- "host": "smtp.live.com",
75
+ "host": "smtp-mail.outlook.com",
76
76
  "port": 587
77
77
  },
78
78
 
@@ -83,6 +83,12 @@
83
83
  "port": 587
84
84
  },
85
85
 
86
+ "Infomaniak": {
87
+ "host": "mail.infomaniak.com",
88
+ "domains": ["ik.me", "ikmail.com", "etik.com"],
89
+ "port": 587
90
+ },
91
+
86
92
  "mail.ee": {
87
93
  "host": "smtp.mail.ee"
88
94
  },
@@ -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.2",
3
+ "version": "6.7.5",
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.41.0",
24
- "aws-sdk": "2.1028.0",
23
+ "@aws-sdk/client-ses": "3.79.0",
24
+ "aws-sdk": "2.1124.0",
25
25
  "bunyan": "1.8.15",
26
- "chai": "4.3.4",
26
+ "chai": "4.3.6",
27
27
  "eslint-config-nodemailer": "1.2.0",
28
- "eslint-config-prettier": "8.3.0",
29
- "grunt": "1.4.1",
28
+ "eslint-config-prettier": "8.5.0",
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
- "mocha": "9.1.3",
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": "12.0.1",
41
- "smtp-server": "3.9.0"
40
+ "sinon": "13.0.2",
41
+ "smtp-server": "3.11.0"
42
42
  },
43
43
  "engines": {
44
44
  "node": ">=6.0.0"