nodemailer 10.3.1 → 10.4.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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## [10.4.0](https://github.com/nodemailer/nodemailer/compare/v10.3.1...v10.4.0) (2026-11-07)
4
+
5
+
6
+ ### Features
7
+
8
+ * let close({ force: true }) end pooled connections that are delivering a message ([aba943c](https://github.com/nodemailer/nodemailer/commit/aba943cf9d24493aca2a3e043df06beadc728feb))
9
+
3
10
  ## [10.3.1](https://github.com/nodemailer/nodemailer/compare/v10.3.0...v10.3.1) (2026-10-29)
4
11
 
5
12
 
@@ -176,8 +176,13 @@ declare class Mail<out T = SentMessageInfo, out D extends TransportOptions = Tra
176
176
  dkim: DKIM | false;
177
177
  transporter: Transport<T, D>;
178
178
  logger: shared.Logger;
179
- /** Closes the transport, the pooled SMTP transport closes its connections */
180
- close: () => void;
179
+ /**
180
+ * Closes the transport, the pooled SMTP transport closes its connections. With `force` the
181
+ * pooled transport also closes connections that are delivering a message
182
+ */
183
+ close: (options?: {
184
+ force?: boolean;
185
+ }) => void;
181
186
  /** Tells whether the transport can take a message right away */
182
187
  isIdle: () => boolean;
183
188
  /** Checks the configuration, the SMTP transports connect and authenticate for it */
@@ -1,3 +1,3 @@
1
1
  export declare const name = "nodemailer";
2
- export declare const version = "10.3.1";
2
+ export declare const version = "10.4.0";
3
3
  export declare const homepage = "https://nodemailer.com/";
@@ -3,5 +3,5 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.homepage = exports.version = exports.name = void 0;
5
5
  exports.name = 'nodemailer';
6
- exports.version = '10.3.1';
6
+ exports.version = '10.4.0';
7
7
  exports.homepage = 'https://nodemailer.com/';
@@ -102,10 +102,16 @@ declare class SMTPPool extends EventEmitter {
102
102
  */
103
103
  send(mail: MailMessage<SMTPPoolSentMessageInfo>, callback: SMTPPoolSendCallback): boolean;
104
104
  /**
105
- * Closes all connections in the pool. If there is a message being sent, the connection
106
- * is closed later
105
+ * Closes the pool. Idle connections are closed at once and a connection in the middle of a
106
+ * delivery finishes it first, unless `force` is set: then it is closed too and its message
107
+ * fails. `force` is for a caller that has given up on a delivery, such as one a server is
108
+ * stalling by trickling its replies, which no socket timeout notices.
109
+ *
110
+ * @param options.force - Also close connections that are delivering a message
107
111
  */
108
- close(): void;
112
+ close(options?: {
113
+ force?: boolean;
114
+ }): void;
109
115
  /**
110
116
  * Returns true if there are free slots in the queue
111
117
  */
@@ -155,10 +155,14 @@ class SMTPPool extends node_events_1.EventEmitter {
155
155
  return true;
156
156
  }
157
157
  /**
158
- * Closes all connections in the pool. If there is a message being sent, the connection
159
- * is closed later
158
+ * Closes the pool. Idle connections are closed at once and a connection in the middle of a
159
+ * delivery finishes it first, unless `force` is set: then it is closed too and its message
160
+ * fails. `force` is for a caller that has given up on a delivery, such as one a server is
161
+ * stalling by trickling its replies, which no socket timeout notices.
162
+ *
163
+ * @param options.force - Also close connections that are delivering a message
160
164
  */
161
- close() {
165
+ close(options) {
162
166
  let connection;
163
167
  const len = this._connections.length;
164
168
  this._closed = true;
@@ -169,9 +173,10 @@ class SMTPPool extends node_events_1.EventEmitter {
169
173
  if (!len && !this._queue.length) {
170
174
  return;
171
175
  }
172
- // remove all available connections
176
+ // remove all available connections, and with `force` the busy ones too
177
+ const force = !!options?.force;
173
178
  for (let i = len - 1; i >= 0; i--) {
174
- if (this._connections[i] && this._connections[i].available) {
179
+ if (this._connections[i] && (force || this._connections[i].available)) {
175
180
  connection = this._connections[i];
176
181
  connection.close();
177
182
  this.logger.info({
@@ -356,7 +361,9 @@ class SMTPPool extends node_events_1.EventEmitter {
356
361
  setTimeout(() => {
357
362
  let delay = 0;
358
363
  if (connection.queueEntry) {
359
- if (this._shouldRequeuOnConnectionClose(connection.queueEntry)) {
364
+ // a closed pool (a forced close ends a delivery on purpose) fails the
365
+ // message rather than queueing it for a retry that would never run
366
+ if (!this._closed && this._shouldRequeuOnConnectionClose(connection.queueEntry)) {
360
367
  delay = this._requeueEntryOnConnectionClose(connection);
361
368
  }
362
369
  else {
@@ -176,8 +176,13 @@ declare class Mail<out T = SentMessageInfo, out D extends TransportOptions = Tra
176
176
  dkim: DKIM | false;
177
177
  transporter: Transport<T, D>;
178
178
  logger: shared.Logger;
179
- /** Closes the transport, the pooled SMTP transport closes its connections */
180
- close: () => void;
179
+ /**
180
+ * Closes the transport, the pooled SMTP transport closes its connections. With `force` the
181
+ * pooled transport also closes connections that are delivering a message
182
+ */
183
+ close: (options?: {
184
+ force?: boolean;
185
+ }) => void;
181
186
  /** Tells whether the transport can take a message right away */
182
187
  isIdle: () => boolean;
183
188
  /** Checks the configuration, the SMTP transports connect and authenticate for it */
@@ -1,3 +1,3 @@
1
1
  export declare const name = "nodemailer";
2
- export declare const version = "10.3.1";
2
+ export declare const version = "10.4.0";
3
3
  export declare const homepage = "https://nodemailer.com/";
@@ -1,4 +1,4 @@
1
1
  // Generated by scripts/build.js from package.json. Do not edit by hand.
2
2
  export const name = 'nodemailer';
3
- export const version = '10.3.1';
3
+ export const version = '10.4.0';
4
4
  export const homepage = 'https://nodemailer.com/';
@@ -102,10 +102,16 @@ declare class SMTPPool extends EventEmitter {
102
102
  */
103
103
  send(mail: MailMessage<SMTPPoolSentMessageInfo>, callback: SMTPPoolSendCallback): boolean;
104
104
  /**
105
- * Closes all connections in the pool. If there is a message being sent, the connection
106
- * is closed later
105
+ * Closes the pool. Idle connections are closed at once and a connection in the middle of a
106
+ * delivery finishes it first, unless `force` is set: then it is closed too and its message
107
+ * fails. `force` is for a caller that has given up on a delivery, such as one a server is
108
+ * stalling by trickling its replies, which no socket timeout notices.
109
+ *
110
+ * @param options.force - Also close connections that are delivering a message
107
111
  */
108
- close(): void;
112
+ close(options?: {
113
+ force?: boolean;
114
+ }): void;
109
115
  /**
110
116
  * Returns true if there are free slots in the queue
111
117
  */
@@ -117,10 +117,14 @@ class SMTPPool extends EventEmitter {
117
117
  return true;
118
118
  }
119
119
  /**
120
- * Closes all connections in the pool. If there is a message being sent, the connection
121
- * is closed later
120
+ * Closes the pool. Idle connections are closed at once and a connection in the middle of a
121
+ * delivery finishes it first, unless `force` is set: then it is closed too and its message
122
+ * fails. `force` is for a caller that has given up on a delivery, such as one a server is
123
+ * stalling by trickling its replies, which no socket timeout notices.
124
+ *
125
+ * @param options.force - Also close connections that are delivering a message
122
126
  */
123
- close() {
127
+ close(options) {
124
128
  let connection;
125
129
  const len = this._connections.length;
126
130
  this._closed = true;
@@ -131,9 +135,10 @@ class SMTPPool extends EventEmitter {
131
135
  if (!len && !this._queue.length) {
132
136
  return;
133
137
  }
134
- // remove all available connections
138
+ // remove all available connections, and with `force` the busy ones too
139
+ const force = !!options?.force;
135
140
  for (let i = len - 1; i >= 0; i--) {
136
- if (this._connections[i] && this._connections[i].available) {
141
+ if (this._connections[i] && (force || this._connections[i].available)) {
137
142
  connection = this._connections[i];
138
143
  connection.close();
139
144
  this.logger.info({
@@ -318,7 +323,9 @@ class SMTPPool extends EventEmitter {
318
323
  setTimeout(() => {
319
324
  let delay = 0;
320
325
  if (connection.queueEntry) {
321
- if (this._shouldRequeuOnConnectionClose(connection.queueEntry)) {
326
+ // a closed pool (a forced close ends a delivery on purpose) fails the
327
+ // message rather than queueing it for a retry that would never run
328
+ if (!this._closed && this._shouldRequeuOnConnectionClose(connection.queueEntry)) {
322
329
  delay = this._requeueEntryOnConnectionClose(connection);
323
330
  }
324
331
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodemailer",
3
- "version": "10.3.1",
3
+ "version": "10.4.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",
@@ -153,21 +153,21 @@
153
153
  },
154
154
  "homepage": "https://nodemailer.com/",
155
155
  "devDependencies": {
156
- "@aws-sdk/client-sesv2": "3.1159.0",
156
+ "@aws-sdk/client-sesv2": "3.1161.0",
157
157
  "@types/node": "20.19.43",
158
158
  "bunyan": "1.8.15",
159
159
  "c8": "12.0.0",
160
- "eslint": "10.13.0",
160
+ "eslint": "10.14.0",
161
161
  "eslint-config-prettier": "10.1.8",
162
- "globals": "17.13.0",
162
+ "globals": "17.14.0",
163
163
  "libbase64": "1.4.1",
164
- "libmime": "5.6.3",
164
+ "libmime": "5.6.4",
165
165
  "libqp": "3.0.1",
166
166
  "mailauth": "8.0.4",
167
167
  "prettier": "3.9.10",
168
168
  "proxy": "1.0.2",
169
169
  "proxy-test-server": "1.0.0",
170
- "smtp-server": "3.21.2",
170
+ "smtp-server": "3.21.3",
171
171
  "tsx": "4.23.15",
172
172
  "typescript": "6.0.3",
173
173
  "typescript-eslint": "8.72.1"