nodemailer 10.5.0 → 10.6.0
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/CHANGELOG.md +13 -0
- package/README.md +4 -0
- package/dist/cjs/fetch/cookies.js +4 -1
- package/dist/cjs/package-info.d.ts +1 -1
- package/dist/cjs/package-info.js +1 -1
- package/dist/cjs/smtp-connection/index.d.ts +3 -0
- package/dist/cjs/smtp-connection/index.js +11 -3
- package/dist/esm/fetch/cookies.js +4 -1
- package/dist/esm/package-info.d.ts +1 -1
- package/dist/esm/package-info.js +1 -1
- package/dist/esm/smtp-connection/index.d.ts +3 -0
- package/dist/esm/smtp-connection/index.js +11 -3
- package/package.json +11 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## [10.6.0](https://github.com/nodemailer/nodemailer/compare/v10.5.0...v10.6.0) (2026-11-15)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* **smtp:** add configurable socketCloseTimeout ([#1916](https://github.com/nodemailer/nodemailer/issues/1916)) ([7f04d0b](https://github.com/nodemailer/nodemailer/commit/7f04d0b78e887191c89775cf4a3063462b222aad)), closes [#1915](https://github.com/nodemailer/nodemailer/issues/1915)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* let Set-Cookie Max-Age take precedence over Expires ([#1917](https://github.com/nodemailer/nodemailer/issues/1917)) ([d6d6d44](https://github.com/nodemailer/nodemailer/commit/d6d6d44f5fbdf61936032d8865a1312c89c1804e))
|
|
14
|
+
* **smtp-connection:** close the TLS socket of an upgraded connection on Node 27 ([4135015](https://github.com/nodemailer/nodemailer/commit/4135015175398aaad5ac6e1866e91a758c432417))
|
|
15
|
+
|
|
3
16
|
## [10.5.0](https://github.com/nodemailer/nodemailer/compare/v10.4.1...v10.5.0) (2026-11-10)
|
|
4
17
|
|
|
5
18
|
|
package/README.md
CHANGED
|
@@ -35,6 +35,10 @@ Work already started by a plugin or a custom `getSocket` hook requires that code
|
|
|
35
35
|
|
|
36
36
|
Other bundled transports (stream, JSON, sendmail and SES) ignore the signal once the message is handed to them, so the message is sent normally. A signal that is already aborted, or aborts while plugins run, still cancels the send with `EABORT` on every transport, as that happens before the transport is called. A `signal` value that is not an `AbortSignal` fails the send with `ECONFIG`. Custom transports can opt in with `supportsAbortSignal: true`; their `send()` must register its abort listener synchronously, check for a pre-aborted signal, stop the work it owns, invoke its callback once, and remove the listener on completion.
|
|
37
37
|
|
|
38
|
+
## SMTP socket close timeout
|
|
39
|
+
|
|
40
|
+
When an SMTP connection closes, Nodemailer ends the socket and destroys it if the server has not closed its side within `socketCloseTimeout` milliseconds (default 5000). Set it to `0` to destroy the socket right away. This applies to SMTP and pooled SMTP, including aborted sends and `transporter.close({ force: true })`. It does not tell you whether the server accepted a message that was in flight.
|
|
41
|
+
|
|
38
42
|
## Having an issue?
|
|
39
43
|
|
|
40
44
|
#### First review the docs
|
|
@@ -131,6 +131,7 @@ class Cookies {
|
|
|
131
131
|
parse(cookieStr) {
|
|
132
132
|
const cookie = {};
|
|
133
133
|
let hasNameValue = false;
|
|
134
|
+
let hasMaxAge = false;
|
|
134
135
|
(cookieStr || '')
|
|
135
136
|
.toString()
|
|
136
137
|
.split(';')
|
|
@@ -158,7 +159,8 @@ class Cookies {
|
|
|
158
159
|
case 'expires': {
|
|
159
160
|
const expires = new Date(value);
|
|
160
161
|
// ignore date if can not parse it
|
|
161
|
-
if (expires.toString() !== 'Invalid Date') {
|
|
162
|
+
if (expires.toString() !== 'Invalid Date' && !hasMaxAge) {
|
|
163
|
+
// Max-Age has precedence when both attributes are present (RFC 6265 5.3)
|
|
162
164
|
cookie.expires = expires;
|
|
163
165
|
}
|
|
164
166
|
break;
|
|
@@ -175,6 +177,7 @@ class Cookies {
|
|
|
175
177
|
break;
|
|
176
178
|
case 'max-age':
|
|
177
179
|
cookie.expires = new Date(Date.now() + (Number(value) || 0) * 1000);
|
|
180
|
+
hasMaxAge = true;
|
|
178
181
|
break;
|
|
179
182
|
case 'secure':
|
|
180
183
|
cookie.secure = true;
|
package/dist/cjs/package-info.js
CHANGED
|
@@ -42,6 +42,8 @@ export interface SMTPConnectionOptions {
|
|
|
42
42
|
greetingTimeout?: number | undefined;
|
|
43
43
|
/** Time of inactivity in ms until the connection is closed, defaults to 10 minutes */
|
|
44
44
|
socketTimeout?: number | undefined;
|
|
45
|
+
/** Time in ms to wait for the peer to close after ending the socket, defaults to 5 seconds. Set to 0 to destroy it immediately */
|
|
46
|
+
socketCloseTimeout?: number | undefined;
|
|
45
47
|
/** Largest single server response to accept in bytes, defaults to 1 MB */
|
|
46
48
|
maxResponseSize?: number | undefined;
|
|
47
49
|
/** Time to wait in ms for the DNS requests to be resolved, defaults to 30 seconds */
|
|
@@ -307,6 +309,7 @@ export type SMTPConnectionResponseAction = (str: string) => void;
|
|
|
307
309
|
* * **greetingTimeout** - Time to wait in ms until greeting message is received from the server (defaults to 30 seconds)
|
|
308
310
|
* * **connectionTimeout** - how many milliseconds to wait for the connection to establish (defaults to 2 minutes)
|
|
309
311
|
* * **socketTimeout** - Time of inactivity until the connection is closed (defaults to 10 minutes)
|
|
312
|
+
* * **socketCloseTimeout** - Time in ms to wait for the peer to close after ending the socket (defaults to 5 seconds, 0 destroys immediately)
|
|
310
313
|
* * **maxResponseSize** - Largest single server response to accept in bytes (defaults to 1 MB)
|
|
311
314
|
* * **dnsTimeout** - Time to wait in ms for the DNS requests to be resolved (defaults to 30 seconds)
|
|
312
315
|
* * **lmtp** - if true, uses LMTP instead of SMTP protocol
|
|
@@ -145,6 +145,7 @@ function maskAuthCommand(cmd) {
|
|
|
145
145
|
* * **greetingTimeout** - Time to wait in ms until greeting message is received from the server (defaults to 30 seconds)
|
|
146
146
|
* * **connectionTimeout** - how many milliseconds to wait for the connection to establish (defaults to 2 minutes)
|
|
147
147
|
* * **socketTimeout** - Time of inactivity until the connection is closed (defaults to 10 minutes)
|
|
148
|
+
* * **socketCloseTimeout** - Time in ms to wait for the peer to close after ending the socket (defaults to 5 seconds, 0 destroys immediately)
|
|
148
149
|
* * **maxResponseSize** - Largest single server response to accept in bytes (defaults to 1 MB)
|
|
149
150
|
* * **dnsTimeout** - Time to wait in ms for the DNS requests to be resolved (defaults to 30 seconds)
|
|
150
151
|
* * **lmtp** - if true, uses LMTP instead of SMTP protocol
|
|
@@ -468,11 +469,18 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
468
469
|
return;
|
|
469
470
|
}
|
|
470
471
|
this._closing = true;
|
|
471
|
-
|
|
472
|
+
// anything but a non-negative finite number keeps the default grace period
|
|
473
|
+
const configuredCloseTimeout = this.options.socketCloseTimeout;
|
|
474
|
+
const socketCloseTimeout = typeof configuredCloseTimeout === 'number' && Number.isFinite(configuredCloseTimeout) && configuredCloseTimeout >= 0
|
|
475
|
+
? configuredCloseTimeout
|
|
476
|
+
: CLOSE_TIMEOUT;
|
|
477
|
+
const closeMethod = this.stage === 'init' || socketCloseTimeout === 0 ? 'destroy' : 'end';
|
|
472
478
|
this.logger.debug({
|
|
473
479
|
tnx: 'smtp'
|
|
474
480
|
}, 'Closing connection to the server using "%s"', closeMethod);
|
|
475
|
-
|
|
481
|
+
// after STARTTLS this is the TLS socket, tear that one down and not the plain socket it
|
|
482
|
+
// wraps (Node 27 exposes the wrapped socket as `.socket`)
|
|
483
|
+
const socket = this._socket;
|
|
476
484
|
// Detach any in-flight DATA stream from the socket so the source stream
|
|
477
485
|
// can be garbage-collected once the socket is gone.
|
|
478
486
|
if (this._currentDataStream) {
|
|
@@ -514,7 +522,7 @@ class SMTPConnection extends node_events_1.EventEmitter {
|
|
|
514
522
|
if (closeMethod === 'end') {
|
|
515
523
|
// end() only closes our side, a server that never closes its own would keep
|
|
516
524
|
// the socket, and the process with it, around for good
|
|
517
|
-
const closeTimer = setTimeout(() => socket.destroy(),
|
|
525
|
+
const closeTimer = setTimeout(() => socket.destroy(), socketCloseTimeout);
|
|
518
526
|
if (typeof closeTimer.unref === 'function') {
|
|
519
527
|
closeTimer.unref();
|
|
520
528
|
}
|
|
@@ -93,6 +93,7 @@ class Cookies {
|
|
|
93
93
|
parse(cookieStr) {
|
|
94
94
|
const cookie = {};
|
|
95
95
|
let hasNameValue = false;
|
|
96
|
+
let hasMaxAge = false;
|
|
96
97
|
(cookieStr || '')
|
|
97
98
|
.toString()
|
|
98
99
|
.split(';')
|
|
@@ -120,7 +121,8 @@ class Cookies {
|
|
|
120
121
|
case 'expires': {
|
|
121
122
|
const expires = new Date(value);
|
|
122
123
|
// ignore date if can not parse it
|
|
123
|
-
if (expires.toString() !== 'Invalid Date') {
|
|
124
|
+
if (expires.toString() !== 'Invalid Date' && !hasMaxAge) {
|
|
125
|
+
// Max-Age has precedence when both attributes are present (RFC 6265 5.3)
|
|
124
126
|
cookie.expires = expires;
|
|
125
127
|
}
|
|
126
128
|
break;
|
|
@@ -137,6 +139,7 @@ class Cookies {
|
|
|
137
139
|
break;
|
|
138
140
|
case 'max-age':
|
|
139
141
|
cookie.expires = new Date(Date.now() + (Number(value) || 0) * 1000);
|
|
142
|
+
hasMaxAge = true;
|
|
140
143
|
break;
|
|
141
144
|
case 'secure':
|
|
142
145
|
cookie.secure = true;
|
package/dist/esm/package-info.js
CHANGED
|
@@ -42,6 +42,8 @@ export interface SMTPConnectionOptions {
|
|
|
42
42
|
greetingTimeout?: number | undefined;
|
|
43
43
|
/** Time of inactivity in ms until the connection is closed, defaults to 10 minutes */
|
|
44
44
|
socketTimeout?: number | undefined;
|
|
45
|
+
/** Time in ms to wait for the peer to close after ending the socket, defaults to 5 seconds. Set to 0 to destroy it immediately */
|
|
46
|
+
socketCloseTimeout?: number | undefined;
|
|
45
47
|
/** Largest single server response to accept in bytes, defaults to 1 MB */
|
|
46
48
|
maxResponseSize?: number | undefined;
|
|
47
49
|
/** Time to wait in ms for the DNS requests to be resolved, defaults to 30 seconds */
|
|
@@ -307,6 +309,7 @@ export type SMTPConnectionResponseAction = (str: string) => void;
|
|
|
307
309
|
* * **greetingTimeout** - Time to wait in ms until greeting message is received from the server (defaults to 30 seconds)
|
|
308
310
|
* * **connectionTimeout** - how many milliseconds to wait for the connection to establish (defaults to 2 minutes)
|
|
309
311
|
* * **socketTimeout** - Time of inactivity until the connection is closed (defaults to 10 minutes)
|
|
312
|
+
* * **socketCloseTimeout** - Time in ms to wait for the peer to close after ending the socket (defaults to 5 seconds, 0 destroys immediately)
|
|
310
313
|
* * **maxResponseSize** - Largest single server response to accept in bytes (defaults to 1 MB)
|
|
311
314
|
* * **dnsTimeout** - Time to wait in ms for the DNS requests to be resolved (defaults to 30 seconds)
|
|
312
315
|
* * **lmtp** - if true, uses LMTP instead of SMTP protocol
|
|
@@ -107,6 +107,7 @@ function maskAuthCommand(cmd) {
|
|
|
107
107
|
* * **greetingTimeout** - Time to wait in ms until greeting message is received from the server (defaults to 30 seconds)
|
|
108
108
|
* * **connectionTimeout** - how many milliseconds to wait for the connection to establish (defaults to 2 minutes)
|
|
109
109
|
* * **socketTimeout** - Time of inactivity until the connection is closed (defaults to 10 minutes)
|
|
110
|
+
* * **socketCloseTimeout** - Time in ms to wait for the peer to close after ending the socket (defaults to 5 seconds, 0 destroys immediately)
|
|
110
111
|
* * **maxResponseSize** - Largest single server response to accept in bytes (defaults to 1 MB)
|
|
111
112
|
* * **dnsTimeout** - Time to wait in ms for the DNS requests to be resolved (defaults to 30 seconds)
|
|
112
113
|
* * **lmtp** - if true, uses LMTP instead of SMTP protocol
|
|
@@ -430,11 +431,18 @@ class SMTPConnection extends EventEmitter {
|
|
|
430
431
|
return;
|
|
431
432
|
}
|
|
432
433
|
this._closing = true;
|
|
433
|
-
|
|
434
|
+
// anything but a non-negative finite number keeps the default grace period
|
|
435
|
+
const configuredCloseTimeout = this.options.socketCloseTimeout;
|
|
436
|
+
const socketCloseTimeout = typeof configuredCloseTimeout === 'number' && Number.isFinite(configuredCloseTimeout) && configuredCloseTimeout >= 0
|
|
437
|
+
? configuredCloseTimeout
|
|
438
|
+
: CLOSE_TIMEOUT;
|
|
439
|
+
const closeMethod = this.stage === 'init' || socketCloseTimeout === 0 ? 'destroy' : 'end';
|
|
434
440
|
this.logger.debug({
|
|
435
441
|
tnx: 'smtp'
|
|
436
442
|
}, 'Closing connection to the server using "%s"', closeMethod);
|
|
437
|
-
|
|
443
|
+
// after STARTTLS this is the TLS socket, tear that one down and not the plain socket it
|
|
444
|
+
// wraps (Node 27 exposes the wrapped socket as `.socket`)
|
|
445
|
+
const socket = this._socket;
|
|
438
446
|
// Detach any in-flight DATA stream from the socket so the source stream
|
|
439
447
|
// can be garbage-collected once the socket is gone.
|
|
440
448
|
if (this._currentDataStream) {
|
|
@@ -476,7 +484,7 @@ class SMTPConnection extends EventEmitter {
|
|
|
476
484
|
if (closeMethod === 'end') {
|
|
477
485
|
// end() only closes our side, a server that never closes its own would keep
|
|
478
486
|
// the socket, and the process with it, around for good
|
|
479
|
-
const closeTimer = setTimeout(() => socket.destroy(),
|
|
487
|
+
const closeTimer = setTimeout(() => socket.destroy(), socketCloseTimeout);
|
|
480
488
|
if (typeof closeTimer.unref === 'function') {
|
|
481
489
|
closeTimer.unref();
|
|
482
490
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodemailer",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.6.0",
|
|
4
4
|
"description": "Easy as cake e-mail sending from your Node.js applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/nodemailer.js",
|
|
@@ -132,6 +132,7 @@
|
|
|
132
132
|
"test:cjs": "NODE_OPTIONS=--no-experimental-require-module node test/package/cjs-smoke.cjs",
|
|
133
133
|
"pretest:bun": "npm run build",
|
|
134
134
|
"test:bun": "bun test --timeout 60000 $(find ./test \\( -name '*-test.ts' -o -name '*.test.ts' \\))",
|
|
135
|
+
"fuzz:addressparser": "node --import tsx scripts/fuzz-addressparser.js",
|
|
135
136
|
"format": "prettier --write \"**/*.{js,cjs,ts,json,md}\"",
|
|
136
137
|
"format:check": "prettier --check \"**/*.{js,cjs,ts,json,md}\"",
|
|
137
138
|
"lint": "eslint . && npm run typecheck",
|
|
@@ -153,26 +154,30 @@
|
|
|
153
154
|
},
|
|
154
155
|
"homepage": "https://nodemailer.com/",
|
|
155
156
|
"devDependencies": {
|
|
156
|
-
"@aws-sdk/client-sesv2": "3.
|
|
157
|
+
"@aws-sdk/client-sesv2": "3.1169.0",
|
|
157
158
|
"@types/node": "20.19.43",
|
|
158
159
|
"bunyan": "1.8.15",
|
|
159
160
|
"c8": "12.0.0",
|
|
160
|
-
"eslint": "10.
|
|
161
|
+
"eslint": "10.15.0",
|
|
161
162
|
"eslint-config-prettier": "10.1.8",
|
|
162
163
|
"globals": "17.14.0",
|
|
163
164
|
"libbase64": "1.4.1",
|
|
164
165
|
"libmime": "5.6.4",
|
|
165
166
|
"libqp": "3.0.1",
|
|
166
|
-
"mailauth": "8.0.
|
|
167
|
-
"prettier": "3.
|
|
167
|
+
"mailauth": "8.0.6",
|
|
168
|
+
"prettier": "3.10.1",
|
|
168
169
|
"proxy": "1.0.2",
|
|
169
170
|
"proxy-test-server": "1.0.0",
|
|
170
|
-
"smtp-server": "3.21.
|
|
171
|
+
"smtp-server": "3.21.4",
|
|
171
172
|
"tsx": "4.23.15",
|
|
172
173
|
"typescript": "6.0.3",
|
|
173
174
|
"typescript-eslint": "8.72.2"
|
|
174
175
|
},
|
|
175
176
|
"engines": {
|
|
176
177
|
"node": ">=20.0.0"
|
|
178
|
+
},
|
|
179
|
+
"overrides": {
|
|
180
|
+
"glob": "14.0.6",
|
|
181
|
+
"minimatch": "11.0.8"
|
|
177
182
|
}
|
|
178
183
|
}
|