apple-mail-mcp 2.20.23 → 2.20.25

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.
Files changed (3) hide show
  1. package/build/cli.js +1173 -668
  2. package/build/index.js +1173 -668
  3. package/package.json +2 -1
package/build/cli.js CHANGED
@@ -48,7 +48,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
48
48
  mod
49
49
  ));
50
50
 
51
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/punycode/index.js
51
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/punycode/index.js
52
52
  function error(type) {
53
53
  throw new RangeError(errors[type]);
54
54
  }
@@ -94,7 +94,7 @@ function ucs2decode(string) {
94
94
  }
95
95
  var maxInt, base, tMin, tMax, skew, damp, initialBias, initialN, delimiter, regexPunycode, regexNonASCII, regexSeparators, errors, baseMinusTMin, floor, stringFromCharCode, basicToDigit, digitToBasic, adapt, decode, encode, toUnicode, toASCII;
96
96
  var init_punycode = __esm({
97
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/punycode/index.js"() {
97
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/punycode/index.js"() {
98
98
  maxInt = 2147483647;
99
99
  base = 36;
100
100
  tMin = 1;
@@ -265,7 +265,7 @@ var init_punycode = __esm({
265
265
  }
266
266
  });
267
267
 
268
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/shared/url.js
268
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/shared/url.js
269
269
  import net from "node:net";
270
270
  import urllib from "node:url";
271
271
  function invalidUrl(input) {
@@ -318,7 +318,7 @@ function normalizeHostname(raw, href) {
318
318
  }
319
319
  var SLASHLESS_AUTHORITY, SURROUNDING_WHITESPACE, LEGACY_TRIM, AUTHORITY, FORBIDDEN_HOST_CHARS, CONTROL_CHARS, parse, resolve;
320
320
  var init_url = __esm({
321
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/shared/url.js"() {
321
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/shared/url.js"() {
322
322
  init_punycode();
323
323
  SLASHLESS_AUTHORITY = /^([a-zA-Z][a-zA-Z0-9+.-]*:)(?!\/\/)([\s\S]+)$/;
324
324
  SURROUNDING_WHITESPACE = /^[\x00-\x20]+|[\x00-\x20]+$/g;
@@ -394,11 +394,11 @@ var init_url = __esm({
394
394
  }
395
395
  });
396
396
 
397
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/fetch/cookies.js
397
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/fetch/cookies.js
398
398
  import net2 from "node:net";
399
399
  var SESSION_TIMEOUT, Cookies, cookies_default;
400
400
  var init_cookies = __esm({
401
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/fetch/cookies.js"() {
401
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/fetch/cookies.js"() {
402
402
  init_url();
403
403
  SESSION_TIMEOUT = 1800;
404
404
  Cookies = class {
@@ -612,21 +612,26 @@ var init_cookies = __esm({
612
612
  }
613
613
  });
614
614
 
615
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/package-info.js
615
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/package-info.js
616
616
  var name, version, homepage;
617
617
  var init_package_info = __esm({
618
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/package-info.js"() {
618
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/package-info.js"() {
619
619
  name = "nodemailer";
620
- version = "10.0.16";
620
+ version = "10.1.1";
621
621
  homepage = "https://nodemailer.com/";
622
622
  }
623
623
  });
624
624
 
625
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/errors.js
626
- var ECONNECTION, ENOAUTH, EOAUTH2, EMAXLIMIT, EMAXRECIPIENTS, ESENDMAIL, ESES, ECONFIG, EPROXY, EFILEACCESS, EURLACCESS, EFETCH;
625
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/errors.js
626
+ var ECONNECTION, ETIMEDOUT, ESOCKET, EENVELOPE, EMESSAGE, ESTREAM, ENOAUTH, EOAUTH2, EMAXLIMIT, EMAXRECIPIENTS, ESENDMAIL, ESES, ECONFIG, EPROXY, EFILEACCESS, EURLACCESS, EFETCH, isTransientError, ERR_ACCESS_DENIED;
627
627
  var init_errors = __esm({
628
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/errors.js"() {
628
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/errors.js"() {
629
629
  ECONNECTION = "ECONNECTION";
630
+ ETIMEDOUT = "ETIMEDOUT";
631
+ ESOCKET = "ESOCKET";
632
+ EENVELOPE = "EENVELOPE";
633
+ EMESSAGE = "EMESSAGE";
634
+ ESTREAM = "ESTREAM";
630
635
  ENOAUTH = "ENOAUTH";
631
636
  EOAUTH2 = "EOAUTH2";
632
637
  EMAXLIMIT = "EMAXLIMIT";
@@ -638,13 +643,15 @@ var init_errors = __esm({
638
643
  EFILEACCESS = "EFILEACCESS";
639
644
  EURLACCESS = "EURLACCESS";
640
645
  EFETCH = "EFETCH";
646
+ isTransientError = (err) => err.responseCode === 421 || err.code === ECONNECTION || err.code === ESOCKET || err.code === ETIMEDOUT;
647
+ ERR_ACCESS_DENIED = "ERR_ACCESS_DENIED";
641
648
  }
642
649
  });
643
650
 
644
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/shared/objects.js
651
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/shared/objects.js
645
652
  var isProtoKey, copyOwnKeys;
646
653
  var init_objects = __esm({
647
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/shared/objects.js"() {
654
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/shared/objects.js"() {
648
655
  isProtoKey = (key) => key === "__proto__";
649
656
  copyOwnKeys = (target, source, skip) => {
650
657
  Object.keys(source || {}).forEach((key) => {
@@ -658,12 +665,17 @@ var init_objects = __esm({
658
665
  }
659
666
  });
660
667
 
661
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/fetch/index.js
668
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/fetch/index.js
662
669
  import http from "node:http";
663
670
  import https from "node:https";
664
671
  import zlib from "node:zlib";
665
672
  import { PassThrough } from "node:stream";
666
673
  import net3 from "node:net";
674
+ function setFetchCode(err) {
675
+ if (err.code !== ERR_ACCESS_DENIED) {
676
+ err.code = EFETCH;
677
+ }
678
+ }
667
679
  function parseFetchUrl(url) {
668
680
  let parsed;
669
681
  try {
@@ -676,6 +688,9 @@ function parseFetchUrl(url) {
676
688
  }
677
689
  return parsed;
678
690
  }
691
+ function fetchPort(parsed) {
692
+ return parsed.port ? Number(parsed.port) : parsed.protocol === "https:" ? 443 : 80;
693
+ }
679
694
  function nmfetch(url, options) {
680
695
  options = options || {};
681
696
  options.fetchRes = options.fetchRes || new PassThrough();
@@ -704,7 +719,7 @@ function nmfetch(url, options) {
704
719
  options.cookie = false;
705
720
  }
706
721
  let method = (options.method || "").toString().trim().toUpperCase() || "GET";
707
- let finished = false;
722
+ let finished3 = false;
708
723
  let cookies;
709
724
  let body;
710
725
  const handler = parsed.protocol === "https:" ? https : http;
@@ -735,11 +750,11 @@ function nmfetch(url, options) {
735
750
  headers["Transfer-Encoding"] = "chunked";
736
751
  body = options.body;
737
752
  body.on("error", (err) => {
738
- if (finished) {
753
+ if (finished3) {
739
754
  return;
740
755
  }
741
- finished = true;
742
- err.code = EFETCH;
756
+ finished3 = true;
757
+ setFetchCode(err);
743
758
  err.sourceUrl = url;
744
759
  fetchRes.emit("error", err);
745
760
  });
@@ -753,7 +768,7 @@ function nmfetch(url, options) {
753
768
  return encodeURIComponent(key) + "=" + encodeURIComponent(value);
754
769
  }).join("&"));
755
770
  } catch (E) {
756
- finished = true;
771
+ finished3 = true;
757
772
  E.code = EFETCH;
758
773
  E.sourceUrl = url;
759
774
  setImmediate(() => fetchRes.emit("error", E));
@@ -772,7 +787,7 @@ function nmfetch(url, options) {
772
787
  method,
773
788
  host: parsed.hostname,
774
789
  path: parsed.path,
775
- port: parsed.port ? parsed.port : parsed.protocol === "https:" ? 443 : 80,
790
+ port: fetchPort(parsed),
776
791
  headers,
777
792
  // Validate TLS certificates by default. Callers that genuinely need to
778
793
  // reach a self-signed/internal host opt out explicitly with
@@ -793,20 +808,20 @@ function nmfetch(url, options) {
793
808
  try {
794
809
  req = handler.request(reqOptions);
795
810
  } catch (E) {
796
- finished = true;
811
+ finished3 = true;
797
812
  setImmediate(() => {
798
- E.code = EFETCH;
813
+ setFetchCode(E);
799
814
  E.sourceUrl = url;
800
815
  fetchRes.emit("error", E);
801
816
  });
802
817
  return fetchRes;
803
818
  }
804
819
  const fail = (err, sourceUrl = url) => {
805
- if (finished) {
820
+ if (finished3) {
806
821
  return;
807
822
  }
808
- finished = true;
809
- err.code = EFETCH;
823
+ finished3 = true;
824
+ setFetchCode(err);
810
825
  err.sourceUrl = sourceUrl;
811
826
  fetchRes.emit("error", err);
812
827
  req.abort();
@@ -816,9 +831,16 @@ function nmfetch(url, options) {
816
831
  req.setTimeout(timeout, () => fail(new Error("Request Timeout")));
817
832
  }
818
833
  req.on("error", (err) => fail(err));
834
+ fetchRes.once("close", () => {
835
+ if (finished3 || fetchRes.readableEnded) {
836
+ return;
837
+ }
838
+ finished3 = true;
839
+ req.destroy();
840
+ });
819
841
  req.on("response", (res) => {
820
842
  let inflate;
821
- if (finished) {
843
+ if (finished3) {
822
844
  return;
823
845
  }
824
846
  switch (res.headers["content-encoding"]) {
@@ -849,17 +871,16 @@ function nmfetch(url, options) {
849
871
  if (!redirectParsed) {
850
872
  return fail(new Error("Unsupported protocol for URL " + redirectUrl), redirectUrl);
851
873
  }
852
- const crossHost = redirectParsed.hostname !== parsed.hostname;
853
- const downgrade = parsed.protocol === "https:" && redirectParsed.protocol === "http:";
854
- if (options.headers && (crossHost || downgrade)) {
874
+ const crossOrigin = redirectParsed.protocol !== parsed.protocol || redirectParsed.hostname !== parsed.hostname || fetchPort(redirectParsed) !== fetchPort(parsed);
875
+ if (options.headers && crossOrigin) {
855
876
  const sensitive = ["authorization", "cookie", "proxy-authorization"];
856
877
  Object.keys(options.headers).forEach((key) => {
857
- if (sensitive.includes(key.toLowerCase())) {
878
+ if (sensitive.includes(key.toLowerCase().trim())) {
858
879
  delete options.headers[key];
859
880
  }
860
881
  });
861
882
  }
862
- finished = true;
883
+ finished3 = true;
863
884
  res.resume();
864
885
  req.abort();
865
886
  return nmfetch(redirectUrl, options);
@@ -875,7 +896,7 @@ function nmfetch(url, options) {
875
896
  let received = 0;
876
897
  source.on("data", (chunk) => {
877
898
  received += chunk.length;
878
- if (received <= maxBytes || finished) {
899
+ if (received <= maxBytes || finished3) {
879
900
  return;
880
901
  }
881
902
  source.unpipe(fetchRes);
@@ -905,7 +926,7 @@ function nmfetch(url, options) {
905
926
  }
906
927
  var MAX_REDIRECTS, DEFAULT_TIMEOUT, DEFAULT_MAX_BYTES, TLS_OPTION_KEYS, fetch_default;
907
928
  var init_fetch = __esm({
908
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/fetch/index.js"() {
929
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/fetch/index.js"() {
909
930
  init_url();
910
931
  init_cookies();
911
932
  init_package_info();
@@ -943,12 +964,13 @@ var init_fetch = __esm({
943
964
  }
944
965
  });
945
966
 
946
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/shared/index.js
967
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/shared/index.js
947
968
  import util from "node:util";
948
969
  import fs from "node:fs";
949
970
  import dns from "node:dns";
950
971
  import net4 from "node:net";
951
972
  import os from "node:os";
973
+ import { finished } from "node:stream";
952
974
  function resolveContent(data, key, options, callback) {
953
975
  if (!callback && typeof options === "function") {
954
976
  callback = options;
@@ -1014,36 +1036,66 @@ function resolveContentValue(data, key, options, callback) {
1014
1036
  }
1015
1037
  setImmediate(() => callback(null, content));
1016
1038
  }
1039
+ function recordStreamErrors(stream) {
1040
+ stream.on("error", (err) => {
1041
+ if (!streamErrors.has(stream)) {
1042
+ streamErrors.set(stream, err);
1043
+ }
1044
+ });
1045
+ }
1046
+ function destroyStream(value) {
1047
+ const stream = value;
1048
+ if (stream && typeof stream.pipe === "function" && typeof stream.destroy === "function" && !stream.destroyed) {
1049
+ stream.destroy();
1050
+ }
1051
+ }
1052
+ function unreadableStreamError(stream) {
1053
+ const err = streamErrors.get(stream) || stream.errored;
1054
+ if (err) {
1055
+ return err;
1056
+ }
1057
+ if (stream.readableEnded || stream.destroyed) {
1058
+ const unreadable = new Error("Content stream was already read or destroyed");
1059
+ unreadable.code = ESTREAM;
1060
+ return unreadable;
1061
+ }
1062
+ return null;
1063
+ }
1017
1064
  function resolveStream(stream, callback) {
1018
1065
  let responded = false;
1019
- const chunks = [];
1020
- let chunklen = 0;
1021
- stream.on("error", (err) => {
1066
+ const respond = (err, value) => {
1022
1067
  if (responded) {
1023
1068
  return;
1024
1069
  }
1025
1070
  responded = true;
1026
- callback(err);
1027
- });
1028
- stream.on("readable", () => {
1029
- let chunk;
1030
- while ((chunk = stream.read()) !== null) {
1031
- chunks.push(chunk);
1032
- chunklen += chunk.length;
1071
+ callback(err, value);
1072
+ };
1073
+ const unreadable = unreadableStreamError(stream);
1074
+ if (unreadable) {
1075
+ stream.on("error", () => false);
1076
+ setImmediate(() => respond(unreadable));
1077
+ return;
1078
+ }
1079
+ const chunks = [];
1080
+ let chunklen = 0;
1081
+ stream.on("data", (chunk) => {
1082
+ if (typeof chunk === "string") {
1083
+ chunk = Buffer.from(chunk);
1033
1084
  }
1085
+ chunks.push(chunk);
1086
+ chunklen += chunk.length;
1034
1087
  });
1035
- stream.on("end", () => {
1036
- if (responded) {
1037
- return;
1088
+ finished(stream, { writable: false }, (err) => {
1089
+ if (err) {
1090
+ return respond(err);
1038
1091
  }
1039
- responded = true;
1040
1092
  let value;
1041
1093
  try {
1042
1094
  value = Buffer.concat(chunks, chunklen);
1043
1095
  } catch (E) {
1044
- return callback(E);
1096
+ return respond(E);
1045
1097
  }
1046
- callback(null, value);
1098
+ respond(null, value);
1047
1099
  });
1048
1100
  }
1049
1101
  function createDefaultLogger(levels) {
@@ -1082,9 +1134,9 @@ function createDefaultLogger(levels) {
1082
1134
  });
1083
1135
  return logger;
1084
1136
  }
1085
- var DNS_TTL, CACHE_CLEANUP_INTERVAL, MAX_CACHE_SIZE, lastCacheCleanup, networkInterfaces, isFamilySupported, resolve2, dnsCache, formatDNSValue, resolveHostname, parseConnectionUrl, _logFunc, getLogger, callbackPromise, parseDataURI, assign, encodeXText;
1137
+ var DNS_TTL, CACHE_CLEANUP_INTERVAL, MAX_CACHE_SIZE, lastCacheCleanup, networkInterfaces, networkInterfacesRead, _readNetworkInterfaces, isFamilySupported, resolve2, dnsCache, formatDNSValue, resolveHostname, parseConnectionUrl, _logFunc, getLogger, callbackPromise, parseDataURI, assign, encodeXText, streamErrors;
1086
1138
  var init_shared = __esm({
1087
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/shared/index.js"() {
1139
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/shared/index.js"() {
1088
1140
  init_url();
1089
1141
  init_fetch();
1090
1142
  init_errors();
@@ -1093,12 +1145,19 @@ var init_shared = __esm({
1093
1145
  CACHE_CLEANUP_INTERVAL = 30 * 1e3;
1094
1146
  MAX_CACHE_SIZE = 1e3;
1095
1147
  lastCacheCleanup = 0;
1096
- try {
1097
- networkInterfaces = os.networkInterfaces();
1098
- } catch (_err) {
1099
- }
1148
+ networkInterfacesRead = false;
1149
+ _readNetworkInterfaces = () => {
1150
+ if (!networkInterfacesRead) {
1151
+ networkInterfacesRead = true;
1152
+ try {
1153
+ networkInterfaces = os.networkInterfaces();
1154
+ } catch (_err) {
1155
+ }
1156
+ }
1157
+ return networkInterfaces;
1158
+ };
1100
1159
  isFamilySupported = (family, allowInternal) => {
1101
- const addresses = Object.values(networkInterfaces || {}).flat();
1160
+ const addresses = Object.values(_readNetworkInterfaces() || {}).flat();
1102
1161
  if (!addresses.length) {
1103
1162
  return true;
1104
1163
  }
@@ -1107,7 +1166,8 @@ var init_shared = __esm({
1107
1166
  resolve2 = (family, hostname, options, callback) => {
1108
1167
  options = options || {};
1109
1168
  if (!isFamilySupported(family, options.allowInternalNetworkInterfaces)) {
1110
- return callback(null, []);
1169
+ callback(null, []);
1170
+ return null;
1111
1171
  }
1112
1172
  const dnsResolver = dns.Resolver ? new dns.Resolver(options) : dns;
1113
1173
  dnsResolver["resolve" + family](hostname, (err, addresses) => {
@@ -1126,6 +1186,7 @@ var init_shared = __esm({
1126
1186
  }
1127
1187
  return callback(null, Array.isArray(addresses) ? addresses : [].concat(addresses || []));
1128
1188
  });
1189
+ return dns.Resolver ? dnsResolver : null;
1129
1190
  };
1130
1191
  dnsCache = /* @__PURE__ */ new Map();
1131
1192
  formatDNSValue = (value, extra) => {
@@ -1180,103 +1241,125 @@ var init_shared = __esm({
1180
1241
  }));
1181
1242
  }
1182
1243
  }
1244
+ let responded = false;
1245
+ let deadline;
1246
+ const respond = (err, result) => {
1247
+ if (responded) {
1248
+ return;
1249
+ }
1250
+ responded = true;
1251
+ clearTimeout(deadline);
1252
+ callback(err, result);
1253
+ };
1254
+ const respondCached = (error2) => {
1255
+ if (!cached) {
1256
+ return false;
1257
+ }
1258
+ dnsCache.set(host, {
1259
+ value: cached.value,
1260
+ expires: Date.now() + (options.dnsTtl || DNS_TTL)
1261
+ });
1262
+ respond(null, formatDNSValue(cached.value, {
1263
+ servername,
1264
+ cached: true,
1265
+ error: error2
1266
+ }));
1267
+ return true;
1268
+ };
1269
+ const resolvers = [];
1270
+ const timeout = Number(options.timeout) || 0;
1271
+ if (timeout > 0) {
1272
+ deadline = setTimeout(() => {
1273
+ for (const resolver of resolvers) {
1274
+ if (typeof resolver.cancel === "function") {
1275
+ resolver.cancel();
1276
+ }
1277
+ }
1278
+ const err = new Error("DNS lookup for " + host + " timed out");
1279
+ err.code = dns.TIMEOUT;
1280
+ if (!respondCached(err)) {
1281
+ respond(err);
1282
+ }
1283
+ }, timeout);
1284
+ }
1183
1285
  let ipv4Addresses = [];
1184
1286
  let ipv6Addresses = [];
1185
1287
  let ipv4Error = null;
1186
1288
  let ipv6Error = null;
1187
- resolve2(4, options.host, options, (err, addresses) => {
1188
- if (err) {
1189
- ipv4Error = err;
1190
- } else {
1191
- ipv4Addresses = addresses || [];
1289
+ let pending = 2;
1290
+ const onResolved = () => {
1291
+ if (--pending || responded) {
1292
+ return;
1192
1293
  }
1193
- resolve2(6, host, options, (err2, addresses2) => {
1194
- if (err2) {
1195
- ipv6Error = err2;
1196
- } else {
1197
- ipv6Addresses = addresses2 || [];
1198
- }
1199
- const allAddresses = ipv4Addresses.concat(ipv6Addresses);
1200
- if (allAddresses.length) {
1294
+ const allAddresses = ipv4Addresses.concat(ipv6Addresses);
1295
+ if (allAddresses.length) {
1296
+ const value = {
1297
+ addresses: allAddresses
1298
+ };
1299
+ dnsCache.set(host, {
1300
+ value,
1301
+ expires: Date.now() + (options.dnsTtl || DNS_TTL)
1302
+ });
1303
+ return respond(null, formatDNSValue(value, {
1304
+ servername,
1305
+ cached: false
1306
+ }));
1307
+ }
1308
+ if (ipv4Error && ipv6Error && respondCached(ipv4Error)) {
1309
+ return;
1310
+ }
1311
+ try {
1312
+ dns.lookup(host, { all: true }, (err, addresses) => {
1313
+ if (err) {
1314
+ if (respondCached(err)) {
1315
+ return;
1316
+ }
1317
+ return respond(err);
1318
+ }
1319
+ const supportedAddresses = addresses ? addresses.filter((addr) => isFamilySupported(addr.family)).map((addr) => addr.address) : [];
1320
+ if (addresses && addresses.length && !supportedAddresses.length) {
1321
+ console.warn(`Failed to resolve IPv${addresses[0].family} addresses with current network`);
1322
+ }
1323
+ if (!supportedAddresses.length && cached) {
1324
+ return respond(null, formatDNSValue(cached.value, {
1325
+ servername,
1326
+ cached: true
1327
+ }));
1328
+ }
1201
1329
  const value = {
1202
- addresses: allAddresses
1330
+ addresses: supportedAddresses.length ? supportedAddresses : [host]
1203
1331
  };
1204
1332
  dnsCache.set(host, {
1205
1333
  value,
1206
1334
  expires: Date.now() + (options.dnsTtl || DNS_TTL)
1207
1335
  });
1208
- return callback(null, formatDNSValue(value, {
1336
+ return respond(null, formatDNSValue(value, {
1209
1337
  servername,
1210
1338
  cached: false
1211
1339
  }));
1340
+ });
1341
+ } catch (lookupErr) {
1342
+ if (respondCached(lookupErr)) {
1343
+ return;
1212
1344
  }
1213
- if (ipv4Error && ipv6Error) {
1214
- if (cached) {
1215
- dnsCache.set(host, {
1216
- value: cached.value,
1217
- expires: Date.now() + (options.dnsTtl || DNS_TTL)
1218
- });
1219
- return callback(null, formatDNSValue(cached.value, {
1220
- servername,
1221
- cached: true,
1222
- error: ipv4Error
1223
- }));
1224
- }
1225
- }
1226
- try {
1227
- dns.lookup(host, { all: true }, (err3, addresses3) => {
1228
- if (err3) {
1229
- if (cached) {
1230
- dnsCache.set(host, {
1231
- value: cached.value,
1232
- expires: Date.now() + (options.dnsTtl || DNS_TTL)
1233
- });
1234
- return callback(null, formatDNSValue(cached.value, {
1235
- servername,
1236
- cached: true,
1237
- error: err3
1238
- }));
1239
- }
1240
- return callback(err3);
1241
- }
1242
- const supportedAddresses = addresses3 ? addresses3.filter((addr) => isFamilySupported(addr.family)).map((addr) => addr.address) : [];
1243
- if (addresses3 && addresses3.length && !supportedAddresses.length) {
1244
- console.warn(`Failed to resolve IPv${addresses3[0].family} addresses with current network`);
1245
- }
1246
- if (!supportedAddresses.length && cached) {
1247
- return callback(null, formatDNSValue(cached.value, {
1248
- servername,
1249
- cached: true
1250
- }));
1251
- }
1252
- const value = {
1253
- addresses: supportedAddresses.length ? supportedAddresses : [host]
1254
- };
1255
- dnsCache.set(host, {
1256
- value,
1257
- expires: Date.now() + (options.dnsTtl || DNS_TTL)
1258
- });
1259
- return callback(null, formatDNSValue(value, {
1260
- servername,
1261
- cached: false
1262
- }));
1263
- });
1264
- } catch (lookupErr) {
1265
- if (cached) {
1266
- dnsCache.set(host, {
1267
- value: cached.value,
1268
- expires: Date.now() + (options.dnsTtl || DNS_TTL)
1269
- });
1270
- return callback(null, formatDNSValue(cached.value, {
1271
- servername,
1272
- cached: true,
1273
- error: lookupErr
1274
- }));
1275
- }
1276
- return callback(ipv4Error || ipv6Error || lookupErr);
1345
+ return respond(ipv4Error || ipv6Error || lookupErr);
1346
+ }
1347
+ };
1348
+ for (const family of [4, 6]) {
1349
+ const resolver = resolve2(family, host, options, (err, addresses) => {
1350
+ if (family === 4) {
1351
+ ipv4Error = err;
1352
+ ipv4Addresses = addresses || [];
1353
+ } else {
1354
+ ipv6Error = err;
1355
+ ipv6Addresses = addresses || [];
1277
1356
  }
1357
+ onResolved();
1278
1358
  });
1279
- });
1359
+ if (resolver) {
1360
+ resolvers.push(resolver);
1361
+ }
1362
+ }
1280
1363
  };
1281
1364
  parseConnectionUrl = (str2) => {
1282
1365
  str2 = str2 || "";
@@ -1461,10 +1544,11 @@ var init_shared = __esm({
1461
1544
  }
1462
1545
  return result;
1463
1546
  };
1547
+ streamErrors = /* @__PURE__ */ new WeakMap();
1464
1548
  }
1465
1549
  });
1466
1550
 
1467
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/mime-funcs/mime-types.js
1551
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/mime-funcs/mime-types.js
1468
1552
  import path from "node:path";
1469
1553
  function detectMimeType(filename) {
1470
1554
  if (!filename) {
@@ -1501,7 +1585,7 @@ function detectExtension(mimeType) {
1501
1585
  }
1502
1586
  var defaultMimeType, defaultExtension, mimeTypes, extensions;
1503
1587
  var init_mime_types = __esm({
1504
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/mime-funcs/mime-types.js"() {
1588
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/mime-funcs/mime-types.js"() {
1505
1589
  defaultMimeType = "application/octet-stream";
1506
1590
  defaultExtension = "bin";
1507
1591
  mimeTypes = /* @__PURE__ */ new Map([
@@ -3566,13 +3650,7 @@ var init_mime_types = __esm({
3566
3650
  }
3567
3651
  });
3568
3652
 
3569
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/base64/index.js
3570
- var base64_exports = {};
3571
- __export(base64_exports, {
3572
- Encoder: () => Encoder,
3573
- encode: () => encode2,
3574
- wrap: () => wrap
3575
- });
3653
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/base64/index.js
3576
3654
  import { Transform } from "node:stream";
3577
3655
  function encode2(buffer) {
3578
3656
  if (typeof buffer === "string") {
@@ -3580,118 +3658,123 @@ function encode2(buffer) {
3580
3658
  }
3581
3659
  return buffer.toString("base64");
3582
3660
  }
3583
- function wrap(str2, lineLength) {
3584
- str2 = (str2 || "").toString();
3585
- lineLength = Math.max(Number(lineLength) || 76, 1);
3586
- if (str2.length <= lineLength) {
3587
- return str2;
3588
- }
3589
- const result = [];
3590
- let pos = 0;
3591
- const chunkLength = lineLength * 1024;
3592
- const wrapRegex = new RegExp(".{" + lineLength + "}", "g");
3593
- while (pos < str2.length) {
3594
- const wrappedLines = str2.substr(pos, chunkLength).replace(wrapRegex, "$&\r\n").trim();
3595
- result.push(wrappedLines);
3596
- pos += chunkLength;
3597
- }
3598
- return result.join("\r\n").trim();
3661
+ function normalizeLineLength(lineLength) {
3662
+ const length = Math.floor(Number(lineLength));
3663
+ return Number.isFinite(length) && length >= 1 ? length : 76;
3664
+ }
3665
+ function wrapBuffer(src, lineLength, final) {
3666
+ const lines = Math.ceil(src.length / lineLength);
3667
+ const complete = Math.max(lines - 1, 0);
3668
+ let rest = src.length - complete * lineLength;
3669
+ const output = Buffer.allocUnsafe(complete * (lineLength + 2) + (final ? rest : 0));
3670
+ let to = 0;
3671
+ for (let from = 0; from < complete * lineLength; from += lineLength) {
3672
+ src.copy(output, to, from, from + lineLength);
3673
+ to += lineLength;
3674
+ output[to++] = 13;
3675
+ output[to++] = 10;
3676
+ }
3677
+ if (final) {
3678
+ to += src.copy(output, to, complete * lineLength);
3679
+ rest = 0;
3680
+ }
3681
+ if (to !== output.length) {
3682
+ throw new Error("Unexpected wrapped length");
3683
+ }
3684
+ return { output, rest };
3599
3685
  }
3600
3686
  var Encoder;
3601
3687
  var init_base64 = __esm({
3602
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/base64/index.js"() {
3688
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/base64/index.js"() {
3603
3689
  Encoder = class extends Transform {
3604
3690
  constructor(options) {
3605
3691
  super();
3606
3692
  this.options = options || {};
3607
3693
  if (this.options.lineLength !== false) {
3608
- this.options.lineLength = this.options.lineLength || 76;
3694
+ this.options.lineLength = normalizeLineLength(this.options.lineLength);
3609
3695
  }
3610
3696
  this._curLine = "";
3611
3697
  this._remainingBytes = false;
3612
3698
  this.inputBytes = 0;
3613
3699
  this.outputBytes = 0;
3614
3700
  }
3701
+ /**
3702
+ * Emits the encoded characters `b64` that follow the current line, keeping what can not be
3703
+ * emitted yet as the new current line
3704
+ *
3705
+ * @internal
3706
+ */
3707
+ _emit(b64, final) {
3708
+ const src = Buffer.from(this._curLine + b64, "latin1");
3709
+ if (!src.length) {
3710
+ return;
3711
+ }
3712
+ let output = src;
3713
+ if (this.options.lineLength) {
3714
+ const wrapped = wrapBuffer(src, this.options.lineLength, final);
3715
+ output = wrapped.output;
3716
+ this._curLine = wrapped.rest ? src.toString("latin1", src.length - wrapped.rest) : "";
3717
+ } else {
3718
+ this._curLine = "";
3719
+ }
3720
+ if (output.length) {
3721
+ this.outputBytes += output.length;
3722
+ this.push(output);
3723
+ }
3724
+ }
3615
3725
  /** @internal */
3616
3726
  _transform(chunk, encoding, done) {
3617
3727
  let buf = encoding !== "buffer" ? Buffer.from(chunk, encoding) : chunk;
3618
3728
  if (!buf || !buf.length) {
3619
- setImmediate(done);
3620
- return;
3729
+ return done();
3621
3730
  }
3622
3731
  this.inputBytes += buf.length;
3623
- if (this._remainingBytes && this._remainingBytes.length) {
3732
+ if (this._remainingBytes) {
3624
3733
  buf = Buffer.concat([this._remainingBytes, buf], this._remainingBytes.length + buf.length);
3625
3734
  this._remainingBytes = false;
3626
3735
  }
3627
- if (buf.length % 3) {
3628
- this._remainingBytes = buf.slice(buf.length - buf.length % 3);
3629
- buf = buf.slice(0, buf.length - buf.length % 3);
3630
- } else {
3631
- this._remainingBytes = false;
3632
- }
3633
- let b64 = this._curLine + encode2(buf);
3634
- if (this.options.lineLength) {
3635
- b64 = wrap(b64, this.options.lineLength);
3636
- const lastLF = b64.lastIndexOf("\n");
3637
- if (lastLF < 0) {
3638
- this._curLine = b64;
3639
- b64 = "";
3640
- } else if (lastLF === b64.length - 1) {
3641
- this._curLine = "";
3642
- } else {
3643
- this._curLine = b64.substring(lastLF + 1);
3644
- b64 = b64.substring(0, lastLF + 1);
3645
- }
3736
+ const extra = buf.length % 3;
3737
+ if (extra) {
3738
+ this._remainingBytes = buf.subarray(buf.length - extra);
3739
+ buf = buf.subarray(0, buf.length - extra);
3646
3740
  }
3647
- if (b64) {
3648
- this.outputBytes += b64.length;
3649
- this.push(Buffer.from(b64, "ascii"));
3650
- }
3651
- setImmediate(done);
3741
+ this._emit(encode2(buf), false);
3742
+ done();
3652
3743
  }
3653
3744
  /** @internal */
3654
3745
  _flush(done) {
3655
- if (this._remainingBytes && this._remainingBytes.length) {
3656
- this._curLine += encode2(this._remainingBytes);
3657
- }
3658
- if (this._curLine) {
3659
- this._curLine = wrap(this._curLine, this.options.lineLength);
3660
- this.outputBytes += this._curLine.length;
3661
- this.push(Buffer.from(this._curLine, "ascii"));
3662
- this._curLine = "";
3663
- }
3746
+ this._emit(this._remainingBytes ? encode2(this._remainingBytes) : "", true);
3747
+ this._remainingBytes = false;
3664
3748
  done();
3665
3749
  }
3666
3750
  };
3667
3751
  }
3668
3752
  });
3669
3753
 
3670
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/qp/index.js
3671
- var qp_exports = {};
3672
- __export(qp_exports, {
3673
- Encoder: () => Encoder2,
3674
- encode: () => encode3,
3675
- wrap: () => wrap2
3676
- });
3754
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/qp/index.js
3677
3755
  import { Transform as Transform2 } from "node:stream";
3678
3756
  function encode3(buffer) {
3679
- if (typeof buffer === "string") {
3680
- buffer = Buffer.from(buffer, "utf-8");
3681
- }
3682
- let result = "";
3683
- let ord;
3684
- for (let i = 0, len = buffer.length; i < len; i++) {
3685
- ord = buffer[i];
3686
- if (checkRanges(ord, QP_RANGES) && !((ord === 32 || ord === 9) && (i === len - 1 || buffer[i + 1] === 10 || buffer[i + 1] === 13))) {
3687
- result += String.fromCharCode(ord);
3757
+ return encodeBytes(typeof buffer === "string" ? Buffer.from(buffer, "utf-8") : buffer);
3758
+ }
3759
+ function encodeBytes(buffer, next, binary, previous) {
3760
+ const len = buffer.length;
3761
+ const output = Buffer.allocUnsafe(len * 3);
3762
+ let pos = 0;
3763
+ for (let i = 0; i < len; i++) {
3764
+ const ord = buffer[i];
3765
+ const following = i + 1 < len ? buffer[i + 1] : next;
3766
+ const lineBreakByte = binary && (ord === 13 || ord === 10) ? ord === 13 ? following === 10 : (i > 0 ? buffer[i - 1] : previous) === 13 : true;
3767
+ if (QP_LITERAL[ord] && lineBreakByte && !(isWhitespace(ord) && (following === void 0 || following === 10 || following === 13))) {
3768
+ output[pos++] = ord;
3688
3769
  continue;
3689
3770
  }
3690
- result += "=" + (ord < 16 ? "0" : "") + ord.toString(16).toUpperCase();
3771
+ output[pos++] = 61;
3772
+ output[pos++] = HEX_DIGITS[Math.floor(ord / 16)];
3773
+ output[pos++] = HEX_DIGITS[ord % 16];
3691
3774
  }
3692
- return result;
3775
+ return output.toString("latin1", 0, pos);
3693
3776
  }
3694
- function wrap2(str2, lineLength) {
3777
+ function wrap(str2, lineLength) {
3695
3778
  str2 = (str2 || "").toString();
3696
3779
  lineLength = Math.max(Number(lineLength) || 76, MIN_LINE_LENGTH);
3697
3780
  if (str2.length <= lineLength) {
@@ -3771,9 +3854,9 @@ function checkRanges(nr, ranges) {
3771
3854
  }
3772
3855
  return false;
3773
3856
  }
3774
- var MIN_LINE_LENGTH, QP_RANGES, Encoder2;
3857
+ var MIN_LINE_LENGTH, QP_RANGES, QP_LITERAL, HEX_DIGITS, isWhitespace, ENCODE_SLICE_SIZE, Encoder2;
3775
3858
  var init_qp = __esm({
3776
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/qp/index.js"() {
3859
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/qp/index.js"() {
3777
3860
  MIN_LINE_LENGTH = 4;
3778
3861
  QP_RANGES = [
3779
3862
  [9],
@@ -3787,6 +3870,13 @@ var init_qp = __esm({
3787
3870
  [62, 126]
3788
3871
  // >?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}
3789
3872
  ];
3873
+ QP_LITERAL = new Uint8Array(256);
3874
+ for (let i = 0; i < 256; i++) {
3875
+ QP_LITERAL[i] = checkRanges(i, QP_RANGES) ? 1 : 0;
3876
+ }
3877
+ HEX_DIGITS = Buffer.from("0123456789ABCDEF", "latin1");
3878
+ isWhitespace = (c) => c === 32 || c === 9;
3879
+ ENCODE_SLICE_SIZE = 64 * 1024;
3790
3880
  Encoder2 = class extends Transform2 {
3791
3881
  constructor(options) {
3792
3882
  super();
@@ -3795,50 +3885,82 @@ var init_qp = __esm({
3795
3885
  this.options.lineLength = this.options.lineLength || 76;
3796
3886
  }
3797
3887
  this._curLine = "";
3888
+ this._remainingBytes = false;
3889
+ this._lastByte = void 0;
3798
3890
  this.inputBytes = 0;
3799
3891
  this.outputBytes = 0;
3800
3892
  }
3801
3893
  /** @internal */
3802
3894
  _transform(chunk, encoding, done) {
3803
- let qp;
3804
- if (encoding !== "buffer") {
3805
- chunk = Buffer.from(chunk, encoding);
3806
- }
3807
- if (!chunk || !chunk.length) {
3895
+ let buf = encoding !== "buffer" ? Buffer.from(chunk, encoding) : chunk;
3896
+ if (!buf || !buf.length) {
3808
3897
  return done();
3809
3898
  }
3810
- this.inputBytes += chunk.length;
3811
- if (this.options.lineLength) {
3812
- qp = this._curLine + encode3(chunk);
3813
- qp = wrap2(qp, this.options.lineLength);
3814
- qp = qp.replace(/(^|\n)([^\n]*)$/, (match, lineBreak, lastLine) => {
3815
- this._curLine = lastLine;
3816
- return lineBreak;
3817
- });
3818
- if (qp) {
3819
- this.outputBytes += qp.length;
3820
- this.push(qp);
3821
- }
3822
- } else {
3823
- qp = encode3(chunk);
3824
- this.outputBytes += qp.length;
3825
- this.push(qp, "ascii");
3899
+ this.inputBytes += buf.length;
3900
+ if (this._remainingBytes) {
3901
+ buf = Buffer.concat([this._remainingBytes, buf], this._remainingBytes.length + buf.length);
3902
+ this._remainingBytes = false;
3826
3903
  }
3904
+ let end = buf.length;
3905
+ while (end > 0 && (isWhitespace(buf[end - 1]) || this.options.binary && buf[end - 1] === 13)) {
3906
+ end--;
3907
+ }
3908
+ if (buf.length - end <= ENCODE_SLICE_SIZE) {
3909
+ this._remainingBytes = end < buf.length ? Buffer.from(buf.subarray(end)) : false;
3910
+ buf = buf.subarray(0, end);
3911
+ }
3912
+ this._encodeSlices(buf);
3827
3913
  done();
3828
3914
  }
3829
3915
  /** @internal */
3830
3916
  _flush(done) {
3917
+ if (this._remainingBytes) {
3918
+ this._encodeSlices(this._remainingBytes);
3919
+ this._remainingBytes = false;
3920
+ }
3831
3921
  if (this._curLine) {
3832
3922
  this.outputBytes += this._curLine.length;
3833
3923
  this.push(this._curLine, "ascii");
3924
+ this._curLine = "";
3834
3925
  }
3835
3926
  done();
3836
3927
  }
3928
+ /**
3929
+ * Encodes the input in slices of ENCODE_SLICE_SIZE bytes. Each slice is told the byte that
3930
+ * follows it, so a slice that ends in whitespace is encoded as if it was not split
3931
+ *
3932
+ * @internal
3933
+ */
3934
+ _encodeSlices(buf) {
3935
+ for (let start = 0; start < buf.length; start += ENCODE_SLICE_SIZE) {
3936
+ const end = Math.min(start + ENCODE_SLICE_SIZE, buf.length);
3937
+ this._encodeSlice(buf.subarray(start, end), end < buf.length ? buf[end] : void 0);
3938
+ this._lastByte = buf[end - 1];
3939
+ }
3940
+ }
3941
+ /** @internal */
3942
+ _encodeSlice(buf, next) {
3943
+ let qp;
3944
+ if (this.options.lineLength) {
3945
+ qp = wrap(this._curLine + encodeBytes(buf, next, this.options.binary, this._lastByte), this.options.lineLength);
3946
+ const lastLF = qp.lastIndexOf("\n");
3947
+ this._curLine = qp.substring(lastLF + 1);
3948
+ qp = qp.substring(0, lastLF + 1);
3949
+ if (qp) {
3950
+ this.outputBytes += qp.length;
3951
+ this.push(qp, "ascii");
3952
+ }
3953
+ } else {
3954
+ qp = encodeBytes(buf, next, this.options.binary, this._lastByte);
3955
+ this.outputBytes += qp.length;
3956
+ this.push(qp, "ascii");
3957
+ }
3958
+ }
3837
3959
  };
3838
3960
  }
3839
3961
  });
3840
3962
 
3841
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/mime-funcs/index.js
3963
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/mime-funcs/index.js
3842
3964
  function isPlainText(value, isParam) {
3843
3965
  const re = isParam ? /[\x00-\x1f\x7f"\u0080-\uFFFF]/ : /[\x00-\x08\x0b\x0c\x0e-\x1f\u0080-\uFFFF]/;
3844
3966
  return typeof value === "string" && !re.test(value);
@@ -4280,7 +4402,7 @@ function safeEncodeURIComponent(str2) {
4280
4402
  }
4281
4403
  var TOKEN;
4282
4404
  var init_mime_funcs = __esm({
4283
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/mime-funcs/index.js"() {
4405
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/mime-funcs/index.js"() {
4284
4406
  init_base64();
4285
4407
  init_qp();
4286
4408
  init_mime_types();
@@ -4289,7 +4411,7 @@ var init_mime_funcs = __esm({
4289
4411
  }
4290
4412
  });
4291
4413
 
4292
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/addressparser/index.js
4414
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/addressparser/index.js
4293
4415
  function _quoteLocalPart(address) {
4294
4416
  const lastAt = address.lastIndexOf("@");
4295
4417
  if (lastAt < 0) {
@@ -4677,7 +4799,7 @@ function addressparser(str2, options) {
4677
4799
  }
4678
4800
  var HAS_WHITESPACE, QUOTED_LOCAL_ADDR, ADDR_SPEC, LOOSE_ADDR_SPEC, LOOSE_TEXT_ADDR, Tokenizer, MAX_NESTED_GROUP_DEPTH, addressparser_default;
4679
4801
  var init_addressparser = __esm({
4680
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/addressparser/index.js"() {
4802
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/addressparser/index.js"() {
4681
4803
  HAS_WHITESPACE = /\s/;
4682
4804
  QUOTED_LOCAL_ADDR = /^("(?:[^"\\]|\\[\s\S])*"@\S+)(?:\s+([\s\S]+))?$/;
4683
4805
  ADDR_SPEC = /^[^@\s]+@[^@\s]+$/;
@@ -4800,11 +4922,11 @@ var init_addressparser = __esm({
4800
4922
  }
4801
4923
  });
4802
4924
 
4803
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/mime-node/last-newline.js
4925
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/mime-node/last-newline.js
4804
4926
  import { Transform as Transform3 } from "node:stream";
4805
4927
  var LastNewline;
4806
4928
  var init_last_newline = __esm({
4807
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/mime-node/last-newline.js"() {
4929
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/mime-node/last-newline.js"() {
4808
4930
  LastNewline = class extends Transform3 {
4809
4931
  constructor() {
4810
4932
  super();
@@ -4834,11 +4956,11 @@ var init_last_newline = __esm({
4834
4956
  }
4835
4957
  });
4836
4958
 
4837
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/mime-node/le-windows.js
4959
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/mime-node/le-windows.js
4838
4960
  import { Transform as Transform4 } from "node:stream";
4839
4961
  var LeWindows;
4840
4962
  var init_le_windows = __esm({
4841
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/mime-node/le-windows.js"() {
4963
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/mime-node/le-windows.js"() {
4842
4964
  LeWindows = class extends Transform4 {
4843
4965
  constructor(options) {
4844
4966
  super(options);
@@ -4876,11 +4998,11 @@ var init_le_windows = __esm({
4876
4998
  }
4877
4999
  });
4878
5000
 
4879
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/mime-node/le-unix.js
5001
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/mime-node/le-unix.js
4880
5002
  import { Transform as Transform5 } from "node:stream";
4881
5003
  var LeUnix;
4882
5004
  var init_le_unix = __esm({
4883
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/mime-node/le-unix.js"() {
5005
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/mime-node/le-unix.js"() {
4884
5006
  LeUnix = class extends Transform5 {
4885
5007
  constructor(options) {
4886
5008
  super(options);
@@ -4911,15 +5033,20 @@ var init_le_unix = __esm({
4911
5033
  }
4912
5034
  });
4913
5035
 
4914
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/mime-node/index.js
5036
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/mime-node/index.js
4915
5037
  import crypto from "node:crypto";
4916
5038
  import fs2 from "node:fs";
4917
- import { PassThrough as PassThrough2 } from "node:stream";
5039
+ import { PassThrough as PassThrough2, finished as finished2, pipeline } from "node:stream";
4918
5040
  import urlModule from "node:url";
5041
+ function abortedError() {
5042
+ const err = new Error("Message stream was closed before the message was generated");
5043
+ err.code = ESTREAM;
5044
+ return err;
5045
+ }
4919
5046
  function normalizeDomain(domain, toUnicode2) {
4920
- const mapper = toUnicode2 ? urlModule.domainToUnicode : urlModule.domainToASCII;
4921
- if (typeof mapper === "function" && !URL_PARSER_UNSAFE.test(domain)) {
4922
- const mapped = mapper(domain);
5047
+ if (typeof urlModule.domainToASCII === "function" && typeof urlModule.domainToUnicode === "function" && !URL_PARSER_UNSAFE.test(domain)) {
5048
+ const ascii = urlModule.domainToASCII(domain);
5049
+ const mapped = ascii && toUnicode2 ? urlModule.domainToUnicode(ascii) : ascii;
4923
5050
  if (mapped) {
4924
5051
  return mapped;
4925
5052
  }
@@ -4929,9 +5056,9 @@ function normalizeDomain(domain, toUnicode2) {
4929
5056
  function _stripBoundaryControls(value) {
4930
5057
  return value.replace(/[\x00-\x1f\x7f]+/g, "");
4931
5058
  }
4932
- var FORMATTED_HEADERS, ATEXT, DOT_ATOM, QUOTED_STRING, PLAIN_ADDRESS, URL_PARSER_UNSAFE, MimeNode, mime_node_default;
5059
+ var FORMATTED_HEADERS, ATEXT, DOT_ATOM, QUOTED_STRING, PLAIN_ADDRESS, URL_PARSER_UNSAFE, PIPELINE_NOOP, MimeNode, mime_node_default;
4933
5060
  var init_mime_node = __esm({
4934
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/mime-node/index.js"() {
5061
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/mime-node/index.js"() {
4935
5062
  init_punycode();
4936
5063
  init_shared();
4937
5064
  init_mime_funcs();
@@ -4949,6 +5076,7 @@ var init_mime_node = __esm({
4949
5076
  QUOTED_STRING = /^"(?:[^"\\]|\\[\s\S])*"$/;
4950
5077
  PLAIN_ADDRESS = /^[^\s"(),:;<>@[\\\]]+@[^\s"(),:;<>@[\\\]]+$/;
4951
5078
  URL_PARSER_UNSAFE = /[/\\?#%\x00-\x20\x7F]/;
5079
+ PIPELINE_NOOP = () => false;
4952
5080
  MimeNode = class _MimeNode {
4953
5081
  constructor(contentType, options) {
4954
5082
  this.nodeCounter = 0;
@@ -5168,11 +5296,7 @@ var init_mime_node = __esm({
5168
5296
  setContent(content) {
5169
5297
  this.content = content;
5170
5298
  if (typeof this.content.pipe === "function") {
5171
- this._contentErrorHandler = (err) => {
5172
- this.content.removeListener("error", this._contentErrorHandler);
5173
- this.content = err;
5174
- };
5175
- this.content.once("error", this._contentErrorHandler);
5299
+ recordStreamErrors(this.content);
5176
5300
  } else if (typeof this.content === "string") {
5177
5301
  this._isPlainText = isPlainText(this.content);
5178
5302
  if (this._isPlainText && hasLongerLines(this.content, 76)) {
@@ -5347,37 +5471,38 @@ var init_mime_node = __esm({
5347
5471
  createReadStream(options) {
5348
5472
  options = options || {};
5349
5473
  const stream = new PassThrough2(options);
5350
- let outputStream = stream;
5351
- let transform;
5352
5474
  this.stream(stream, options, (err) => {
5353
5475
  if (err) {
5354
- outputStream.emit("error", err);
5476
+ stream.destroy(err);
5355
5477
  return;
5356
5478
  }
5357
5479
  stream.end();
5358
5480
  });
5359
- for (let i = 0, len = this._transforms.length; i < len; i++) {
5360
- transform = typeof this._transforms[i] === "function" ? this._transforms[i]() : this._transforms[i];
5361
- outputStream.once("error", (err) => {
5362
- transform.emit("error", err);
5363
- });
5364
- outputStream = outputStream.pipe(transform);
5365
- }
5366
- transform = new LastNewline();
5367
- outputStream.once("error", (err) => {
5368
- transform.emit("error", err);
5481
+ stream.once("close", () => {
5482
+ if (!stream.writableFinished) {
5483
+ this._destroyContentStreams();
5484
+ }
5369
5485
  });
5370
- outputStream = outputStream.pipe(transform);
5371
- for (let i = 0, len = this._processFuncs.length; i < len; i++) {
5372
- transform = this._processFuncs[i];
5373
- outputStream = transform(outputStream);
5486
+ const stages = [stream];
5487
+ for (const transform of this._transforms) {
5488
+ stages.push(typeof transform === "function" ? transform() : transform);
5489
+ }
5490
+ stages.push(new LastNewline());
5491
+ let outputStream = pipeline(stages, PIPELINE_NOOP);
5492
+ for (const processFunc of this._processFuncs) {
5493
+ const input = outputStream;
5494
+ outputStream = processFunc(input);
5495
+ if (outputStream !== input) {
5496
+ finished2(outputStream, (err) => {
5497
+ if (err) {
5498
+ input.destroy();
5499
+ }
5500
+ });
5501
+ }
5374
5502
  }
5375
5503
  if (this.newline) {
5376
5504
  const winbreak = ["win", "windows", "dos", "\r\n"].includes(this.newline.toString().toLowerCase());
5377
- const newlineTransform = winbreak ? new LeWindows() : new LeUnix();
5378
- const stream2 = outputStream.pipe(newlineTransform);
5379
- outputStream.on("error", (err) => stream2.emit("error", err));
5380
- return stream2;
5505
+ outputStream = pipeline(outputStream, winbreak ? new LeWindows() : new LeUnix(), PIPELINE_NOOP);
5381
5506
  }
5382
5507
  return outputStream;
5383
5508
  }
@@ -5403,19 +5528,41 @@ var init_mime_node = __esm({
5403
5528
  }
5404
5529
  stream(outputStream, options, done) {
5405
5530
  const transferEncoding = this.getTransferEncoding();
5406
- let contentStream;
5407
- let localStream;
5531
+ let activeStreams = [];
5408
5532
  let returned = false;
5409
5533
  const callback = (err) => {
5410
5534
  if (returned) {
5411
5535
  return;
5412
5536
  }
5413
5537
  returned = true;
5538
+ outputStream.removeListener("close", onOutputClose);
5414
5539
  done(err);
5415
5540
  };
5541
+ function onOutputClose() {
5542
+ for (const stream of activeStreams) {
5543
+ stream.destroy();
5544
+ }
5545
+ return callback(abortedError());
5546
+ }
5547
+ const readInto = (...streams) => {
5548
+ if (!activeStreams.length) {
5549
+ outputStream.once("close", onOutputClose);
5550
+ }
5551
+ activeStreams = streams;
5552
+ };
5553
+ const aborted = () => {
5554
+ if (outputStream.destroyed) {
5555
+ callback(abortedError());
5556
+ return true;
5557
+ }
5558
+ return false;
5559
+ };
5416
5560
  const finalize = () => {
5417
5561
  let childId = 0;
5418
5562
  const processChildNode = () => {
5563
+ if (aborted()) {
5564
+ return;
5565
+ }
5419
5566
  if (childId >= this.childNodes.length) {
5420
5567
  outputStream.write("\r\n--" + this.boundary + "--\r\n");
5421
5568
  return callback();
@@ -5436,83 +5583,74 @@ var init_mime_node = __esm({
5436
5583
  }
5437
5584
  };
5438
5585
  const sendContent = () => {
5439
- if (this.content) {
5440
- if (Object.prototype.toString.call(this.content) === "[object Error]") {
5441
- return callback(this.content);
5442
- }
5443
- if (typeof this.content.pipe === "function") {
5444
- this.content.removeListener("error", this._contentErrorHandler);
5445
- this._contentErrorHandler = (err) => callback(err);
5446
- this.content.once("error", this._contentErrorHandler);
5447
- }
5448
- const createStream = () => {
5449
- if (["quoted-printable", "base64"].includes(transferEncoding)) {
5450
- contentStream = new (transferEncoding === "base64" ? base64_exports : qp_exports).Encoder(options);
5451
- contentStream.pipe(outputStream, {
5452
- end: false
5453
- });
5454
- contentStream.once("end", finalize);
5455
- contentStream.once("error", (err) => callback(err));
5456
- localStream = this._getStream(this.content);
5457
- localStream.pipe(contentStream);
5458
- } else {
5459
- localStream = this._getStream(this.content);
5460
- localStream.pipe(outputStream, {
5461
- end: false
5462
- });
5463
- localStream.once("end", finalize);
5464
- }
5465
- localStream.once("error", (err) => callback(err));
5466
- };
5467
- if (this.content._resolve) {
5468
- const chunks = [];
5469
- let chunklen = 0;
5470
- let returned2 = false;
5471
- const sourceStream = this._getStream(this.content);
5472
- sourceStream.on("error", (err) => {
5473
- if (returned2) {
5474
- return;
5475
- }
5476
- returned2 = true;
5477
- callback(err);
5478
- });
5479
- sourceStream.on("readable", () => {
5480
- let chunk;
5481
- while ((chunk = sourceStream.read()) !== null) {
5482
- chunks.push(chunk);
5483
- chunklen += chunk.length;
5484
- }
5485
- });
5486
- sourceStream.on("end", () => {
5487
- if (returned2) {
5488
- return;
5489
- }
5490
- returned2 = true;
5491
- this.content._resolve = false;
5492
- this.content._resolvedValue = Buffer.concat(chunks, chunklen);
5493
- setImmediate(createStream);
5586
+ if (aborted()) {
5587
+ return;
5588
+ }
5589
+ if (!this.content) {
5590
+ return setImmediate(finalize);
5591
+ }
5592
+ const createStream = () => {
5593
+ if (aborted()) {
5594
+ return;
5595
+ }
5596
+ const contentError = this._takeStreamContent(this.content);
5597
+ if (contentError) {
5598
+ return callback(contentError);
5599
+ }
5600
+ const localStream = this._getStream(this.content);
5601
+ if (["quoted-printable", "base64"].includes(transferEncoding)) {
5602
+ const contentStream = transferEncoding === "base64" ? new Encoder(options) : (
5603
+ // outside of text a lone CR or LF is data, encoding it keeps it from being
5604
+ // turned into a line break by a newline transform or the receiving side
5605
+ new Encoder2(Object.assign({}, options, { binary: !/^text\//i.test(this.contentType || "") }))
5606
+ );
5607
+ readInto(localStream, contentStream);
5608
+ contentStream.pipe(outputStream, {
5609
+ end: false
5494
5610
  });
5611
+ pipeline(localStream, contentStream, (err) => err && callback(err));
5612
+ finished2(contentStream, { writable: false }, (err) => err ? callback(err) : finalize());
5495
5613
  } else {
5496
- setImmediate(createStream);
5614
+ readInto(localStream);
5615
+ localStream.pipe(outputStream, {
5616
+ end: false
5617
+ });
5618
+ finished2(localStream, { writable: false }, (err) => err ? callback(err) : finalize());
5497
5619
  }
5498
- return;
5620
+ };
5621
+ if (this.content._resolve) {
5622
+ const sourceStream = this._getStream(this.content);
5623
+ readInto(sourceStream);
5624
+ resolveStream(sourceStream, (err, value) => {
5625
+ if (err) {
5626
+ return callback(err);
5627
+ }
5628
+ if (returned) {
5629
+ return;
5630
+ }
5631
+ this.content._resolve = false;
5632
+ this.content._resolvedValue = value;
5633
+ setImmediate(createStream);
5634
+ });
5635
+ } else {
5636
+ setImmediate(createStream);
5499
5637
  }
5500
- return setImmediate(finalize);
5501
5638
  };
5502
5639
  if (this._raw) {
5503
5640
  setImmediate(() => {
5504
- if (Object.prototype.toString.call(this._raw) === "[object Error]") {
5505
- return callback(this._raw);
5641
+ if (aborted()) {
5642
+ return;
5506
5643
  }
5507
- if (typeof this._raw.pipe === "function") {
5508
- this._raw.removeListener("error", this._contentErrorHandler);
5644
+ const rawError = this._takeStreamContent(this._raw);
5645
+ if (rawError) {
5646
+ return callback(rawError);
5509
5647
  }
5510
5648
  const raw = this._getStream(this._raw);
5649
+ readInto(raw);
5511
5650
  raw.pipe(outputStream, {
5512
5651
  end: false
5513
5652
  });
5514
- raw.on("error", (err) => outputStream.emit("error", err));
5515
- raw.on("end", finalize);
5653
+ finished2(raw, { writable: false }, (err) => err ? callback(err) : finalize());
5516
5654
  });
5517
5655
  } else {
5518
5656
  outputStream.write(this.buildHeaders() + "\r\n\r\n");
@@ -5620,11 +5758,7 @@ var init_mime_node = __esm({
5620
5758
  setRaw(raw) {
5621
5759
  this._raw = raw;
5622
5760
  if (this._raw && typeof this._raw.pipe === "function") {
5623
- this._contentErrorHandler = (err) => {
5624
- this._raw.removeListener("error", this._contentErrorHandler);
5625
- this._raw = err;
5626
- };
5627
- this._raw.once("error", this._contentErrorHandler);
5761
+ recordStreamErrors(this._raw);
5628
5762
  }
5629
5763
  return this;
5630
5764
  }
@@ -5649,6 +5783,36 @@ var init_mime_node = __esm({
5649
5783
  }
5650
5784
  return false;
5651
5785
  }
5786
+ /**
5787
+ * Destroys the content streams of this node and of every node below it
5788
+ *
5789
+ * @internal
5790
+ */
5791
+ _destroyContentStreams() {
5792
+ destroyStream(this.content);
5793
+ destroyStream(this._raw);
5794
+ for (const child of this.childNodes) {
5795
+ child._destroyContentStreams();
5796
+ }
5797
+ }
5798
+ /**
5799
+ * Checks that a content value can still be read before the node streams it. A stream is
5800
+ * refused once it errored, ended or was destroyed: piping it would either never finish or
5801
+ * produce an empty body without any error
5802
+ *
5803
+ * @param content Node content or raw value
5804
+ * @returns The error to stop with, or null when the content can be read
5805
+ * @internal
5806
+ */
5807
+ _takeStreamContent(content) {
5808
+ if (Object.prototype.toString.call(content) === "[object Error]") {
5809
+ return content;
5810
+ }
5811
+ if (!content || typeof content.pipe !== "function" || content._resolvedValue) {
5812
+ return null;
5813
+ }
5814
+ return unreadableStreamError(content);
5815
+ }
5652
5816
  /**
5653
5817
  * Detects and returns handle to a stream related with the content.
5654
5818
  *
@@ -6059,14 +6223,14 @@ var init_mime_node = __esm({
6059
6223
  }
6060
6224
  });
6061
6225
 
6062
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/mail-composer/index.js
6226
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/mail-composer/index.js
6063
6227
  function isContentObject(value) {
6064
6228
  const content = value;
6065
6229
  return typeof value === "object" && !!(content.content || content.path || content.href || content.raw);
6066
6230
  }
6067
6231
  var MailComposer, mail_composer_default;
6068
6232
  var init_mail_composer = __esm({
6069
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/mail-composer/index.js"() {
6233
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/mail-composer/index.js"() {
6070
6234
  init_mime_node();
6071
6235
  init_mime_funcs();
6072
6236
  init_shared();
@@ -6553,7 +6717,7 @@ var init_mail_composer = __esm({
6553
6717
  }
6554
6718
  });
6555
6719
 
6556
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/dkim/message-parser.js
6720
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/dkim/message-parser.js
6557
6721
  import { Transform as Transform6 } from "node:stream";
6558
6722
  function _trimFieldName(str2) {
6559
6723
  let start = 0;
@@ -6568,7 +6732,7 @@ function _trimFieldName(str2) {
6568
6732
  }
6569
6733
  var MessageParser, message_parser_default;
6570
6734
  var init_message_parser = __esm({
6571
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/dkim/message-parser.js"() {
6735
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/dkim/message-parser.js"() {
6572
6736
  MessageParser = class extends Transform6 {
6573
6737
  constructor(options) {
6574
6738
  super(options);
@@ -6638,7 +6802,7 @@ var init_message_parser = __esm({
6638
6802
  if (data.length > headerPos) {
6639
6803
  const chunk = data.slice(headerPos);
6640
6804
  this.bodySize += chunk.length;
6641
- setImmediate(() => this.push(chunk));
6805
+ this.push(chunk);
6642
6806
  }
6643
6807
  return false;
6644
6808
  }
@@ -6665,7 +6829,7 @@ var init_message_parser = __esm({
6665
6829
  this.bodySize += chunk.length;
6666
6830
  this.push(chunk);
6667
6831
  }
6668
- setImmediate(callback);
6832
+ callback();
6669
6833
  }
6670
6834
  /** @internal */
6671
6835
  _flush(callback) {
@@ -6696,12 +6860,12 @@ var init_message_parser = __esm({
6696
6860
  }
6697
6861
  });
6698
6862
 
6699
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/dkim/relaxed-body.js
6863
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/dkim/relaxed-body.js
6700
6864
  import { Transform as Transform7 } from "node:stream";
6701
6865
  import crypto2 from "node:crypto";
6702
6866
  var CHAR_CR, CHAR_LF, CHAR_SPACE, CHAR_TAB, CRLF, EMPTY_LINES, RelaxedBody, relaxed_body_default;
6703
6867
  var init_relaxed_body = __esm({
6704
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/dkim/relaxed-body.js"() {
6868
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/dkim/relaxed-body.js"() {
6705
6869
  CHAR_CR = 13;
6706
6870
  CHAR_LF = 10;
6707
6871
  CHAR_SPACE = 32;
@@ -6823,7 +6987,7 @@ var init_relaxed_body = __esm({
6823
6987
  }
6824
6988
  });
6825
6989
 
6826
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/dkim/sign.js
6990
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/dkim/sign.js
6827
6991
  import crypto3 from "node:crypto";
6828
6992
  function unsupportedHashAlgoError(hashAlgo) {
6829
6993
  const err = new Error('Unsupported DKIM hash algorithm "' + hashAlgo + '"');
@@ -6900,7 +7064,7 @@ function relaxedHeaderLine(line) {
6900
7064
  }
6901
7065
  var sign_default;
6902
7066
  var init_sign = __esm({
6903
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/dkim/sign.js"() {
7067
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/dkim/sign.js"() {
6904
7068
  init_punycode();
6905
7069
  init_mime_funcs();
6906
7070
  init_errors();
@@ -6910,14 +7074,14 @@ var init_sign = __esm({
6910
7074
  }
6911
7075
  });
6912
7076
 
6913
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/dkim/index.js
7077
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/dkim/index.js
6914
7078
  import { PassThrough as PassThrough3 } from "node:stream";
6915
7079
  import fs3 from "node:fs";
6916
7080
  import path2 from "node:path";
6917
7081
  import crypto4 from "node:crypto";
6918
7082
  var DKIM_ALGO, MAX_MESSAGE_SIZE, DKIMSigner, DKIM, dkim_default;
6919
7083
  var init_dkim = __esm({
6920
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/dkim/index.js"() {
7084
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/dkim/index.js"() {
6921
7085
  init_message_parser();
6922
7086
  init_relaxed_body();
6923
7087
  init_sign();
@@ -6944,50 +7108,64 @@ var init_dkim = __esm({
6944
7108
  this.output = output;
6945
7109
  this.output.usingCache = false;
6946
7110
  this.hasErrored = false;
6947
- this.input.on("error", (err) => {
7111
+ this.input.on("error", (err) => this.fail(err));
7112
+ this.output.once("close", () => {
7113
+ if (this.output.writableFinished) {
7114
+ return;
7115
+ }
6948
7116
  this.hasErrored = true;
7117
+ this.input.unpipe();
7118
+ this.input.destroy();
6949
7119
  this.cleanup();
6950
- output.emit("error", err);
6951
7120
  });
6952
7121
  }
7122
+ /**
7123
+ * Ends the output with an error and releases the cache file
7124
+ */
7125
+ fail(err) {
7126
+ this.hasErrored = true;
7127
+ this.cleanup();
7128
+ this.output.destroy(err);
7129
+ }
6953
7130
  cleanup() {
6954
7131
  if (!this.cache || !this.cachePath) {
6955
7132
  return;
6956
7133
  }
7134
+ const cache = this.cache;
7135
+ this.cache = false;
7136
+ cache.destroy();
6957
7137
  fs3.unlink(this.cachePath, () => false);
6958
7138
  }
6959
7139
  createReadCache() {
6960
7140
  this.cache = fs3.createReadStream(this.cachePath);
6961
- this.cache.once("error", (err) => {
6962
- this.cleanup();
6963
- this.output.emit("error", err);
6964
- });
7141
+ this.cache.once("error", (err) => this.fail(err));
6965
7142
  this.cache.once("close", () => {
6966
7143
  this.cleanup();
6967
7144
  });
6968
7145
  this.cache.pipe(this.output);
6969
7146
  }
6970
7147
  sendNextChunk() {
6971
- if (this.hasErrored) {
6972
- return;
6973
- }
6974
- if (this.readPos >= this.chunks.length) {
6975
- if (!this.cache) {
6976
- this.output.end();
7148
+ while (!this.hasErrored) {
7149
+ if (this.readPos >= this.chunks.length) {
7150
+ if (!this.cache) {
7151
+ this.output.end();
7152
+ return;
7153
+ }
7154
+ return this.createReadCache();
7155
+ }
7156
+ const chunk = this.chunks[this.readPos++];
7157
+ if (this.output.write(chunk) === false) {
7158
+ this.output.once("drain", () => {
7159
+ this.sendNextChunk();
7160
+ });
6977
7161
  return;
6978
7162
  }
6979
- return this.createReadCache();
6980
7163
  }
6981
- const chunk = this.chunks[this.readPos++];
6982
- if (this.output.write(chunk) === false) {
6983
- this.output.once("drain", () => {
6984
- this.sendNextChunk();
6985
- });
6986
- return;
6987
- }
6988
- setImmediate(() => this.sendNextChunk());
6989
7164
  }
6990
7165
  sendSignedOutput() {
7166
+ if (this.hasErrored) {
7167
+ return;
7168
+ }
6991
7169
  let keyPos = 0;
6992
7170
  const signNextKey = () => {
6993
7171
  if (keyPos >= this.keys.length) {
@@ -7006,9 +7184,7 @@ var init_dkim = __esm({
7006
7184
  skipFields: this.options.skipFields
7007
7185
  });
7008
7186
  } catch (err) {
7009
- this.hasErrored = true;
7010
- this.cleanup();
7011
- this.output.emit("error", err);
7187
+ this.fail(err);
7012
7188
  return;
7013
7189
  }
7014
7190
  if (dkimField) {
@@ -7026,16 +7202,17 @@ var init_dkim = __esm({
7026
7202
  this.output.usingCache = true;
7027
7203
  this.cache = fs3.createWriteStream(this.cachePath);
7028
7204
  this.cache.once("error", (err) => {
7029
- this.cleanup();
7030
7205
  this.relaxedBody.unpipe(this.cache);
7031
7206
  this.relaxedBody.on("readable", () => {
7032
7207
  while (this.relaxedBody.read() !== null) {
7033
7208
  }
7034
7209
  });
7035
- this.hasErrored = true;
7036
- this.output.emit("error", err);
7210
+ this.fail(err);
7037
7211
  });
7038
7212
  this.cache.once("close", () => {
7213
+ if (this.hasErrored) {
7214
+ return;
7215
+ }
7039
7216
  this.sendSignedOutput();
7040
7217
  });
7041
7218
  this.relaxedBody.removeAllListeners("readable");
@@ -7105,7 +7282,7 @@ var init_dkim = __esm({
7105
7282
  try {
7106
7283
  signer.signStream();
7107
7284
  } catch (_E) {
7108
- output.emit("error", sign_default.unsupportedHashAlgoError(signer.hashAlgo));
7285
+ signer.fail(sign_default.unsupportedHashAlgoError(signer.hashAlgo));
7109
7286
  return;
7110
7287
  }
7111
7288
  if (writeValue) {
@@ -7121,7 +7298,7 @@ var init_dkim = __esm({
7121
7298
  }
7122
7299
  });
7123
7300
 
7124
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.js
7301
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.js
7125
7302
  import net5 from "node:net";
7126
7303
  import tls from "node:tls";
7127
7304
  function httpProxyClient(proxyUrl, destinationPort, destinationHost, tlsOptions, callback) {
@@ -7139,6 +7316,7 @@ function httpProxyClient(proxyUrl, destinationPort, destinationHost, tlsOptions,
7139
7316
  return;
7140
7317
  }
7141
7318
  const proxy = parse(proxyUrl);
7319
+ const authority = (net5.isIPv6(unbracket(destinationHost)) ? "[" + unbracket(destinationHost) + "]" : destinationHost) + ":" + destinationPort;
7142
7320
  const connectOptions = {
7143
7321
  host: proxy.hostname,
7144
7322
  port: Number(proxy.port) ? Number(proxy.port) : proxy.protocol === "https:" ? 443 : 80
@@ -7150,30 +7328,83 @@ function httpProxyClient(proxyUrl, destinationPort, destinationHost, tlsOptions,
7150
7328
  } else {
7151
7329
  connect = net5.connect.bind(net5);
7152
7330
  }
7331
+ const timeout = Number(tlsOptions.timeout) || httpProxyClient.timeout || 30 * 1e3;
7153
7332
  let socket;
7154
- let finished = false;
7155
- const tempSocketErr = (err) => {
7156
- if (finished) {
7333
+ let finished3 = false;
7334
+ let timer;
7335
+ const cleanup = () => {
7336
+ clearTimeout(timer);
7337
+ socket.removeListener("data", onSocketData);
7338
+ socket.removeListener("error", fail);
7339
+ socket.removeListener("close", onEarlyClose);
7340
+ };
7341
+ function fail(err) {
7342
+ if (finished3) {
7157
7343
  return;
7158
7344
  }
7159
- finished = true;
7345
+ finished3 = true;
7346
+ cleanup();
7160
7347
  try {
7161
7348
  socket.destroy();
7162
7349
  } catch (_E) {
7163
7350
  }
7164
7351
  done(err);
7165
- };
7166
- const timeoutErr = () => {
7167
- const err = new Error("Proxy socket timed out");
7168
- err.code = "ETIMEDOUT";
7169
- tempSocketErr(err);
7170
- };
7352
+ }
7353
+ function onEarlyClose() {
7354
+ const err = new Error("Proxy closed the connection before the tunnel was established");
7355
+ err.code = EPROXY;
7356
+ fail(err);
7357
+ }
7358
+ const chunks = [];
7359
+ let received = 0;
7360
+ let tail = "";
7361
+ function onSocketData(chunk) {
7362
+ if (finished3) {
7363
+ return;
7364
+ }
7365
+ const window = tail + chunk.toString("binary");
7366
+ const windowEnd = window.indexOf("\r\n\r\n");
7367
+ chunks.push(chunk);
7368
+ received += chunk.length;
7369
+ tail = window.slice(-3);
7370
+ if (windowEnd < 0) {
7371
+ if (received > MAX_RESPONSE_HEADER_BYTES) {
7372
+ const err = new Error("Proxy response headers too large");
7373
+ err.code = EPROXY;
7374
+ fail(err);
7375
+ }
7376
+ return;
7377
+ }
7378
+ socket.removeListener("data", onSocketData);
7379
+ socket.pause();
7380
+ const headerEnd = received - window.length + windowEnd;
7381
+ const response = Buffer.concat(chunks, received);
7382
+ if (response.length > headerEnd + 4) {
7383
+ socket.unshift(response.subarray(headerEnd + 4));
7384
+ }
7385
+ const match = response.toString("binary", 0, headerEnd).match(/^HTTP\/\d+\.\d+ (\d+)/i);
7386
+ if (!match || (match[1] || "").charAt(0) !== "2") {
7387
+ const err = new Error("Invalid response from proxy" + (match && ": " + match[1] || ""));
7388
+ err.code = EPROXY;
7389
+ return fail(err);
7390
+ }
7391
+ finished3 = true;
7392
+ cleanup();
7393
+ const resumeOnData = (event) => {
7394
+ if (event === "data") {
7395
+ socket.removeListener("newListener", resumeOnData);
7396
+ socket.resume();
7397
+ }
7398
+ };
7399
+ socket.on("newListener", resumeOnData);
7400
+ return done(null, socket);
7401
+ }
7171
7402
  socket = connect(connectOptions, () => {
7172
- if (finished) {
7403
+ if (finished3) {
7173
7404
  return;
7174
7405
  }
7175
7406
  const reqHeaders = {
7176
- Host: destinationHost + ":" + destinationPort,
7407
+ Host: authority,
7177
7408
  Connection: "close"
7178
7409
  };
7179
7410
  if (proxy.auth) {
@@ -7181,75 +7412,35 @@ function httpProxyClient(proxyUrl, destinationPort, destinationHost, tlsOptions,
7181
7412
  }
7182
7413
  socket.write(
7183
7414
  // HTTP method
7184
- "CONNECT " + destinationHost + ":" + destinationPort + " HTTP/1.1\r\n" + // HTTP request headers
7415
+ "CONNECT " + authority + " HTTP/1.1\r\n" + // HTTP request headers
7185
7416
  Object.keys(reqHeaders).map((key) => key + ": " + reqHeaders[key]).join("\r\n") + // End request
7186
7417
  "\r\n\r\n"
7187
7418
  );
7188
- const chunks = [];
7189
- let received = 0;
7190
- let tail = "";
7191
- const onSocketData = (chunk) => {
7192
- let match;
7193
- if (finished) {
7194
- return;
7195
- }
7196
- const window = tail + chunk.toString("binary");
7197
- const windowEnd = window.indexOf("\r\n\r\n");
7198
- chunks.push(chunk);
7199
- received += chunk.length;
7200
- tail = window.slice(-3);
7201
- if (windowEnd >= 0) {
7202
- socket.removeListener("data", onSocketData);
7203
- const headerEnd = received - window.length + windowEnd;
7204
- const response = Buffer.concat(chunks, received).toString("binary");
7205
- const headers = response.substr(0, headerEnd);
7206
- const remainder = response.substr(headerEnd + 4);
7207
- if (remainder) {
7208
- socket.unshift(Buffer.from(remainder, "binary"));
7209
- }
7210
- finished = true;
7211
- match = headers.match(/^HTTP\/\d+\.\d+ (\d+)/i);
7212
- if (!match || (match[1] || "").charAt(0) !== "2") {
7213
- try {
7214
- socket.destroy();
7215
- } catch (_E) {
7216
- }
7217
- const err = new Error("Invalid response from proxy" + (match && ": " + match[1] || ""));
7218
- err.code = EPROXY;
7219
- return done(err);
7220
- }
7221
- socket.removeListener("error", tempSocketErr);
7222
- socket.removeListener("timeout", timeoutErr);
7223
- socket.setTimeout(0);
7224
- return done(null, socket);
7225
- }
7226
- if (received > MAX_RESPONSE_HEADER_BYTES) {
7227
- socket.removeListener("data", onSocketData);
7228
- const err = new Error("Proxy response headers too large");
7229
- err.code = EPROXY;
7230
- return tempSocketErr(err);
7231
- }
7232
- };
7233
7419
  socket.on("data", onSocketData);
7234
7420
  });
7235
- socket.setTimeout(httpProxyClient.timeout || 30 * 1e3);
7236
- socket.on("timeout", timeoutErr);
7237
- socket.once("error", tempSocketErr);
7421
+ timer = setTimeout(() => {
7422
+ const err = new Error("Proxy socket timed out");
7423
+ err.code = ETIMEDOUT;
7424
+ fail(err);
7425
+ }, timeout);
7426
+ socket.once("error", fail);
7427
+ socket.once("close", onEarlyClose);
7238
7428
  }
7239
- var MAX_RESPONSE_HEADER_BYTES, http_proxy_client_default;
7429
+ var MAX_RESPONSE_HEADER_BYTES, unbracket, http_proxy_client_default;
7240
7430
  var init_http_proxy_client = __esm({
7241
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.js"() {
7431
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/smtp-connection/http-proxy-client.js"() {
7242
7432
  init_url();
7243
7433
  init_errors();
7244
7434
  MAX_RESPONSE_HEADER_BYTES = 64 * 1024;
7435
+ unbracket = (host) => typeof host === "string" && host.startsWith("[") && host.endsWith("]") ? host.slice(1, -1) : host;
7245
7436
  http_proxy_client_default = httpProxyClient;
7246
7437
  }
7247
7438
  });
7248
7439
 
7249
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/mailer/mail-message.js
7440
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/mailer/mail-message.js
7250
7441
  var hasOwn, MailMessage;
7251
7442
  var init_mail_message = __esm({
7252
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/mailer/mail-message.js"() {
7443
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/mailer/mail-message.js"() {
7253
7444
  init_shared();
7254
7445
  init_mime_node();
7255
7446
  init_mime_funcs();
@@ -7362,6 +7553,26 @@ var init_mail_message = __esm({
7362
7553
  };
7363
7554
  setImmediate(() => resolveNext());
7364
7555
  }
7556
+ /**
7557
+ * Destroys the content streams of the message once sending failed. A stream that was not
7558
+ * read to the end would otherwise keep the file or the socket behind it open
7559
+ */
7560
+ releaseStreams() {
7561
+ const data = this.data;
7562
+ const values = [data.html, data.text, data.watchHtml, data.amp, data.raw, data.icalEvent];
7563
+ for (const key of ["attachments", "alternatives"]) {
7564
+ if (Array.isArray(data[key])) {
7565
+ values.push(...data[key]);
7566
+ }
7567
+ }
7568
+ for (const value of values) {
7569
+ if (value && typeof value === "object") {
7570
+ destroyStream(value);
7571
+ destroyStream(value.content);
7572
+ destroyStream(value.raw);
7573
+ }
7574
+ }
7575
+ }
7365
7576
  normalize(callback) {
7366
7577
  const envelope = this.message.getEnvelope();
7367
7578
  const messageId = this.message.messageId();
@@ -7506,7 +7717,7 @@ var init_mail_message = __esm({
7506
7717
  }
7507
7718
  });
7508
7719
 
7509
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/mailer/index.js
7720
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/mailer/index.js
7510
7721
  import { EventEmitter } from "node:events";
7511
7722
  import util2 from "node:util";
7512
7723
  import net6 from "node:net";
@@ -7514,7 +7725,7 @@ import dns2 from "node:dns";
7514
7725
  import crypto5 from "node:crypto";
7515
7726
  var DEFAULT_MAX_RECIPIENTS, Mail, mailer_default;
7516
7727
  var init_mailer = __esm({
7517
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/mailer/index.js"() {
7728
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/mailer/index.js"() {
7518
7729
  init_shared();
7519
7730
  init_mime_types();
7520
7731
  init_mail_composer();
@@ -7610,6 +7821,10 @@ var init_mailer = __esm({
7610
7821
  this.getSocket = false;
7611
7822
  }
7612
7823
  const mail = new MailMessage(this, data);
7824
+ const fail = (err) => {
7825
+ mail.releaseStreams();
7826
+ done(err);
7827
+ };
7613
7828
  this.logger.debug({
7614
7829
  tnx: "transport",
7615
7830
  name: this.transporter.name,
@@ -7623,7 +7838,7 @@ var init_mailer = __esm({
7623
7838
  tnx: "plugin",
7624
7839
  action: "compile"
7625
7840
  }, "PluginCompile Error: %s", err.message);
7626
- return done(err);
7841
+ return fail(err);
7627
7842
  }
7628
7843
  let recipientCount;
7629
7844
  try {
@@ -7638,7 +7853,7 @@ var init_mailer = __esm({
7638
7853
  tnx: "transport",
7639
7854
  action: "send"
7640
7855
  }, "Compile Error: %s", err2.message);
7641
- return done(err2);
7856
+ return fail(err2);
7642
7857
  }
7643
7858
  const maxRecipients = mail.data.maxRecipients === void 0 ? DEFAULT_MAX_RECIPIENTS : mail.data.maxRecipients;
7644
7859
  if (maxRecipients && recipientCount > maxRecipients) {
@@ -7649,7 +7864,7 @@ var init_mailer = __esm({
7649
7864
  tnx: "transport",
7650
7865
  action: "send"
7651
7866
  }, "Send Error: %s", err2.message);
7652
- return done(err2);
7867
+ return fail(err2);
7653
7868
  }
7654
7869
  this._processPlugins("stream", mail, (err2) => {
7655
7870
  if (err2) {
@@ -7658,7 +7873,7 @@ var init_mailer = __esm({
7658
7873
  tnx: "plugin",
7659
7874
  action: "stream"
7660
7875
  }, "PluginStream Error: %s", err2.message);
7661
- return done(err2);
7876
+ return fail(err2);
7662
7877
  }
7663
7878
  if (mail.data.dkim || this.dkim) {
7664
7879
  mail.message.processFunc((input) => {
@@ -7673,6 +7888,7 @@ var init_mailer = __esm({
7673
7888
  }
7674
7889
  this.transporter.send(mail, (...args) => {
7675
7890
  if (args[0]) {
7891
+ mail.releaseStreams();
7676
7892
  this.logger.error({
7677
7893
  err: args[0],
7678
7894
  tnx: "transport",
@@ -7738,6 +7954,9 @@ var init_mailer = __esm({
7738
7954
  const proxy = parse(proxyUrl);
7739
7955
  this.getSocket = (options, callback) => {
7740
7956
  const protocol = proxy.protocol.replace(/:$/, "").toLowerCase();
7957
+ const configuredTimeout = Number(this.options.connectionTimeout) || 0;
7958
+ const connectStartedAt = Number(options.connectStartedAt) || Date.now();
7959
+ const connectionTimeout = configuredTimeout ? Math.max(connectStartedAt + configuredTimeout - Date.now(), 1) : void 0;
7741
7960
  if (this.meta.has("proxy_handler_" + protocol)) {
7742
7961
  return this.meta.get("proxy_handler_" + protocol)(proxy, options, callback);
7743
7962
  }
@@ -7745,7 +7964,7 @@ var init_mailer = __esm({
7745
7964
  // Connect using a HTTP CONNECT method
7746
7965
  case "http":
7747
7966
  case "https":
7748
- http_proxy_client_default(proxy.href, options.port, options.host, this.options.tls || {}, (err2, socket) => {
7967
+ http_proxy_client_default(proxy.href, options.port, options.host, connectionTimeout ? Object.assign({}, this.options.tls, { timeout: connectionTimeout }) : this.options.tls || {}, (err2, socket) => {
7749
7968
  if (err2) {
7750
7969
  return callback(err2);
7751
7970
  }
@@ -7779,6 +7998,9 @@ var init_mailer = __esm({
7779
7998
  },
7780
7999
  command: "connect"
7781
8000
  };
8001
+ if (connectionTimeout) {
8002
+ connectionOpts.timeout = connectionTimeout;
8003
+ }
7782
8004
  if (proxy.username || proxy.password) {
7783
8005
  const username = proxy.username || "";
7784
8006
  const password = proxy.password || "";
@@ -7806,11 +8028,11 @@ var init_mailer = __esm({
7806
8028
  if (net6.isIP(proxy.hostname)) {
7807
8029
  return connect(proxy.hostname);
7808
8030
  }
7809
- return dns2.resolve(proxy.hostname, (err2, address) => {
8031
+ return dns2.lookup(proxy.hostname, (err2, address) => {
7810
8032
  if (err2) {
7811
8033
  return callback(err2);
7812
8034
  }
7813
- connect(Array.isArray(address) ? address[0] : address);
8035
+ connect(address);
7814
8036
  });
7815
8037
  }
7816
8038
  }
@@ -7859,11 +8081,11 @@ var init_mailer = __esm({
7859
8081
  }
7860
8082
  });
7861
8083
 
7862
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.js
8084
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.js
7863
8085
  import { Transform as Transform8 } from "node:stream";
7864
8086
  var INSERT_LF, INSERT_LF_DOT, INSERT_CR, INSERT_DOT, DataStream;
7865
8087
  var init_data_stream = __esm({
7866
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.js"() {
8088
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/smtp-connection/data-stream.js"() {
7867
8089
  INSERT_LF = Buffer.from("\n");
7868
8090
  INSERT_LF_DOT = Buffer.from("\n.");
7869
8091
  INSERT_CR = Buffer.from("\r");
@@ -7950,13 +8172,26 @@ var init_data_stream = __esm({
7950
8172
  }
7951
8173
  });
7952
8174
 
7953
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/smtp-connection/index.js
8175
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/smtp-connection/index.js
7954
8176
  import { EventEmitter as EventEmitter2 } from "node:events";
7955
8177
  import net7 from "node:net";
7956
8178
  import tls2 from "node:tls";
7957
8179
  import os2 from "node:os";
7958
8180
  import crypto6 from "node:crypto";
7959
8181
  import { PassThrough as PassThrough4 } from "node:stream";
8182
+ function shuffle(list) {
8183
+ const result = list.slice();
8184
+ for (let i = result.length - 1; i > 0; i--) {
8185
+ const j = Math.floor(Math.random() * (i + 1));
8186
+ [result[i], result[j]] = [result[j], result[i]];
8187
+ }
8188
+ return result;
8189
+ }
8190
+ function timeoutError(message, timeoutType) {
8191
+ const err = new Error(message);
8192
+ err.timeoutType = timeoutType;
8193
+ return err;
8194
+ }
7960
8195
  function decodeServerResponse(str2) {
7961
8196
  if (!str2) {
7962
8197
  return str2;
@@ -7970,16 +8205,19 @@ function isPartialResponse(str2) {
7970
8205
  function isPartialLine(line) {
7971
8206
  return /^\d+-/.test(line);
7972
8207
  }
7973
- var CONNECTION_TIMEOUT, SOCKET_TIMEOUT, GREETING_TIMEOUT, DNS_TIMEOUT, TEARDOWN_NOOP, MAX_RESPONSE_SIZE, SMTPConnection, smtp_connection_default;
8208
+ var CONNECTION_TIMEOUT, SOCKET_TIMEOUT, GREETING_TIMEOUT, DNS_TIMEOUT, CLOSE_TIMEOUT, KEEPALIVE_DELAY, TEARDOWN_NOOP, MAX_RESPONSE_SIZE, SMTPConnection, smtp_connection_default;
7974
8209
  var init_smtp_connection = __esm({
7975
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/smtp-connection/index.js"() {
8210
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/smtp-connection/index.js"() {
7976
8211
  init_package_info();
7977
8212
  init_data_stream();
7978
8213
  init_shared();
8214
+ init_errors();
7979
8215
  CONNECTION_TIMEOUT = 2 * 60 * 1e3;
7980
8216
  SOCKET_TIMEOUT = 10 * 60 * 1e3;
7981
8217
  GREETING_TIMEOUT = 30 * 1e3;
7982
8218
  DNS_TIMEOUT = 30 * 1e3;
8219
+ CLOSE_TIMEOUT = 5 * 1e3;
8220
+ KEEPALIVE_DELAY = 30 * 1e3;
7983
8221
  TEARDOWN_NOOP = () => {
7984
8222
  };
7985
8223
  MAX_RESPONSE_SIZE = 1024 * 1024;
@@ -8029,8 +8267,8 @@ var init_smtp_connection = __esm({
8029
8267
  this._maxAllowedSize = 0;
8030
8268
  this._responseActions = [];
8031
8269
  this._recipientQueue = [];
8032
- this._greetingTimeout = false;
8033
- this._connectionTimeout = false;
8270
+ this._phaseTimer = false;
8271
+ this._plaintextEhlo = false;
8034
8272
  this._destroyed = false;
8035
8273
  this._closing = false;
8036
8274
  this._currentDataStream = false;
@@ -8041,14 +8279,23 @@ var init_smtp_connection = __esm({
8041
8279
  this._onSocketClose = () => this._onClose();
8042
8280
  this._onSocketEnd = () => this._onEnd();
8043
8281
  this._onSocketTimeout = () => this._onTimeout();
8044
- this._onConnectionSocketError = (err) => this._onConnectionError(err, "ESOCKET");
8045
- this._connectionAttemptId = 0;
8282
+ this._onConnectionSocketError = (err) => this._onError(err, "ESOCKET", false, "CONN");
8046
8283
  }
8047
8284
  /**
8048
8285
  * Creates a connection to a SMTP server and sets up connection
8049
8286
  * listener
8050
8287
  */
8051
8288
  connect(connectCallback) {
8289
+ if (this._connectCalled && !this._destroyed) {
8290
+ const err = this._formatError("Cannot connect - connect() was already called for this connection", "ECONNECTION", false, "API");
8291
+ if (typeof connectCallback === "function") {
8292
+ setImmediate(() => connectCallback(err));
8293
+ return;
8294
+ }
8295
+ this.logger.warn({ tnx: "smtp" }, "%s", err.message);
8296
+ return;
8297
+ }
8298
+ this._connectCalled = true;
8052
8299
  if (typeof connectCallback === "function") {
8053
8300
  this._connectCallback = connectCallback;
8054
8301
  this.once("connect", () => {
@@ -8063,11 +8310,13 @@ var init_smtp_connection = __esm({
8063
8310
  return connectCallback(this._formatError(isDestroyedMessage, "ECONNECTION", false, "CONN"));
8064
8311
  }
8065
8312
  }
8313
+ const connectionTimeout = this.options.connectionTimeout || CONNECTION_TIMEOUT;
8314
+ this._connectionDeadline = (this._connectStartedAt || Date.now()) + connectionTimeout;
8066
8315
  let opts = {
8067
8316
  port: this.port,
8068
8317
  host: this.host,
8069
8318
  allowInternalNetworkInterfaces: this.allowInternalNetworkInterfaces,
8070
- timeout: this.options.dnsTimeout || DNS_TIMEOUT
8319
+ timeout: Math.min(this.options.dnsTimeout || DNS_TIMEOUT, connectionTimeout)
8071
8320
  };
8072
8321
  if (this.options.localAddress) {
8073
8322
  opts.localAddress = this.options.localAddress;
@@ -8092,7 +8341,6 @@ var init_smtp_connection = __esm({
8092
8341
  return this._resolveAndConnect(opts, (_resolved) => {
8093
8342
  try {
8094
8343
  this._socket.connect(this.port, this.host, () => {
8095
- this._socket.setKeepAlive(true);
8096
8344
  if (this.secureConnection && !this.alreadySecured) {
8097
8345
  return this._upgradeConnection((err) => {
8098
8346
  if (err) {
@@ -8118,8 +8366,32 @@ var init_smtp_connection = __esm({
8118
8366
  }
8119
8367
  }
8120
8368
  return this._resolveAndConnect(opts, (resolved) => {
8121
- this._fallbackAddresses = (resolved._addresses || []).filter((addr) => addr !== opts.host);
8122
- this._connectOpts = Object.assign({}, opts);
8369
+ let addresses = resolved._addresses || [];
8370
+ if (opts.localAddress) {
8371
+ const localFamily = net7.isIPv6(opts.localAddress) ? 6 : 4;
8372
+ const sameFamily = addresses.filter((addr) => net7.isIP(addr) === localFamily);
8373
+ addresses = sameFamily.length ? sameFamily : addresses;
8374
+ }
8375
+ if (addresses.length > 1) {
8376
+ const ipv6 = addresses.filter((addr) => net7.isIPv6(addr));
8377
+ const ipv4 = addresses.filter((addr) => !net7.isIPv6(addr));
8378
+ const ordered = shuffle(ipv6).concat(shuffle(ipv4));
8379
+ opts.host = this.host;
8380
+ opts.autoSelectFamily = true;
8381
+ if (!ipv6.length || !ipv4.length) {
8382
+ const remaining = this._connectionDeadline - Date.now();
8383
+ opts.autoSelectFamilyAttemptTimeout = Math.max(Math.floor(remaining / ordered.length), 10);
8384
+ }
8385
+ opts.lookup = ((hostname, lookupOptions, callback) => {
8386
+ if (lookupOptions && lookupOptions.all) {
8387
+ const all = ordered.map((address) => ({ address, family: net7.isIPv6(address) ? 6 : 4 }));
8388
+ return setImmediate(() => callback(null, all));
8389
+ }
8390
+ setImmediate(() => callback(null, ordered[0], net7.isIPv6(ordered[0]) ? 6 : 4));
8391
+ });
8392
+ } else if (addresses.length) {
8393
+ opts.host = addresses[0];
8394
+ }
8123
8395
  this._connectToHost(opts, this.secureConnection);
8124
8396
  });
8125
8397
  }
@@ -8162,17 +8434,9 @@ var init_smtp_connection = __esm({
8162
8434
  if (this._destroyed || this._closing) {
8163
8435
  return;
8164
8436
  }
8165
- this._connectionAttemptId++;
8166
- const currentAttemptId = this._connectionAttemptId;
8167
8437
  const connectFn = secure ? tls2.connect : net7.connect;
8168
8438
  try {
8169
- this._socket = connectFn(opts, () => {
8170
- if (this._connectionAttemptId !== currentAttemptId) {
8171
- return;
8172
- }
8173
- this._socket.setKeepAlive(true);
8174
- this._onConnect();
8175
- });
8439
+ this._socket = connectFn(opts, () => this._onConnect());
8176
8440
  this._setupConnectionHandlers();
8177
8441
  } catch (E) {
8178
8442
  setImmediate(() => this._onError(E, "ECONNECTION", false, "CONN"));
@@ -8184,43 +8448,37 @@ var init_smtp_connection = __esm({
8184
8448
  * @internal
8185
8449
  */
8186
8450
  _setupConnectionHandlers() {
8187
- this._connectionTimeout = setTimeout(() => {
8188
- this._onConnectionError("Connection timeout", "ETIMEDOUT");
8189
- }, this.options.connectionTimeout || CONNECTION_TIMEOUT);
8451
+ this._startPhase(Math.max((this._connectionDeadline || Date.now()) - Date.now(), 0), timeoutError("Connection timeout", "CONNECT_TIMEOUT"));
8190
8452
  this._socket.on("error", this._onConnectionSocketError);
8191
8453
  }
8192
8454
  /**
8193
- * Handles connection errors with fallback to alternative addresses
8455
+ * Starts the timer of a connection phase: connecting, waiting for the greeting or a TLS
8456
+ * upgrade. The phases follow one another, so starting one ends the one before
8194
8457
  *
8195
- * @param err Error object or message
8196
- * @param code Error code
8458
+ * @param timeout Time the phase may take
8459
+ * @param err Error to fail with when it takes longer
8197
8460
  * @internal
8198
8461
  */
8199
- _onConnectionError(err, code) {
8200
- clearTimeout(this._connectionTimeout);
8201
- const canFallback = this._fallbackAddresses && this._fallbackAddresses.length && this.stage === "init" && !this._destroyed;
8202
- if (!canFallback) {
8203
- this._onError(err, code, false, "CONN");
8204
- return;
8205
- }
8206
- const nextHost = this._fallbackAddresses.shift();
8207
- this.logger.info({
8208
- tnx: "network",
8209
- failedHost: this._connectOpts.host,
8210
- nextHost,
8211
- error: err.message || err
8212
- }, "Connection to %s failed, trying %s", this._connectOpts.host, nextHost);
8213
- if (this._socket) {
8214
- try {
8215
- this._socket.removeListener("error", this._onConnectionSocketError);
8216
- this._socket.on("error", TEARDOWN_NOOP);
8217
- this._socket.destroy();
8218
- } catch (_E) {
8219
- }
8220
- this._socket = null;
8221
- }
8222
- this._connectOpts.host = nextHost;
8223
- this._connectToHost(this._connectOpts, this.secureConnection);
8462
+ _startPhase(timeout, err) {
8463
+ this._clearPhase();
8464
+ this._phaseTimer = setTimeout(() => {
8465
+ this._phaseTimer = false;
8466
+ this._onError(err, "ETIMEDOUT", false, "CONN");
8467
+ }, timeout);
8468
+ }
8469
+ /**
8470
+ * Time the greeting or a STARTTLS upgrade may take: greetingTimeout, cut short by what is left
8471
+ * of connectionTimeout
8472
+ *
8473
+ * @internal
8474
+ */
8475
+ _remainingSetupTime() {
8476
+ return Math.min(this.options.greetingTimeout || GREETING_TIMEOUT, Math.max((this._connectionDeadline || Infinity) - Date.now(), 1));
8477
+ }
8478
+ /** @internal */
8479
+ _clearPhase() {
8480
+ clearTimeout(this._phaseTimer);
8481
+ this._phaseTimer = false;
8224
8482
  }
8225
8483
  /**
8226
8484
  * Sends QUIT
@@ -8233,8 +8491,7 @@ var init_smtp_connection = __esm({
8233
8491
  * Closes the connection to the server
8234
8492
  */
8235
8493
  close() {
8236
- clearTimeout(this._connectionTimeout);
8237
- clearTimeout(this._greetingTimeout);
8494
+ this._clearPhase();
8238
8495
  this._responseActions = [];
8239
8496
  if (this._closing) {
8240
8497
  return;
@@ -8257,6 +8514,7 @@ var init_smtp_connection = __esm({
8257
8514
  if (stream) {
8258
8515
  stream.removeListener("error", onStreamError);
8259
8516
  stream.on("error", TEARDOWN_NOOP);
8517
+ stream.destroy();
8260
8518
  }
8261
8519
  this._pendingSend = false;
8262
8520
  }
@@ -8271,6 +8529,13 @@ var init_smtp_connection = __esm({
8271
8529
  socket.removeListener("error", this._onConnectionSocketError);
8272
8530
  socket.on("error", TEARDOWN_NOOP);
8273
8531
  socket[closeMethod]();
8532
+ if (closeMethod === "end") {
8533
+ const closeTimer = setTimeout(() => socket.destroy(), CLOSE_TIMEOUT);
8534
+ if (typeof closeTimer.unref === "function") {
8535
+ closeTimer.unref();
8536
+ }
8537
+ socket.once("close", () => clearTimeout(closeTimer));
8538
+ }
8274
8539
  } catch (_E) {
8275
8540
  }
8276
8541
  }
@@ -8457,12 +8722,8 @@ var init_smtp_connection = __esm({
8457
8722
  const startTime = Date.now();
8458
8723
  this._setEnvelope(envelope, (err, info) => {
8459
8724
  if (err) {
8460
- const stream2 = new PassThrough4();
8461
- if (typeof message.pipe === "function") {
8462
- message.pipe(stream2);
8463
- } else {
8464
- stream2.write(message);
8465
- stream2.end();
8725
+ if (typeof message.destroy === "function") {
8726
+ message.destroy();
8466
8727
  }
8467
8728
  return callback(err);
8468
8729
  }
@@ -8514,7 +8775,7 @@ var init_smtp_connection = __esm({
8514
8775
  */
8515
8776
  _onConnect() {
8516
8777
  const socket = this._socket;
8517
- clearTimeout(this._connectionTimeout);
8778
+ this._clearPhase();
8518
8779
  this.logger.info({
8519
8780
  tnx: "network",
8520
8781
  localAddress: socket.localAddress,
@@ -8539,14 +8800,35 @@ var init_smtp_connection = __esm({
8539
8800
  socket.once("end", this._onSocketEnd);
8540
8801
  socket.setTimeout(this.options.socketTimeout || SOCKET_TIMEOUT);
8541
8802
  socket.on("timeout", this._onSocketTimeout);
8542
- this._greetingTimeout = setTimeout(() => {
8543
- if (this._socket && !this._destroyed && this._responseActions[0] === this._actionGreeting) {
8544
- this._onError("Greeting never received", "ETIMEDOUT", false, "CONN");
8545
- }
8546
- }, this.options.greetingTimeout || GREETING_TIMEOUT);
8803
+ if (typeof socket.setKeepAlive === "function") {
8804
+ socket.setKeepAlive(true, KEEPALIVE_DELAY);
8805
+ }
8806
+ if (typeof socket.setNoDelay === "function") {
8807
+ socket.setNoDelay(true);
8808
+ }
8809
+ this._startPhase(this._remainingSetupTime(), timeoutError("Greeting never received", "GREETING_TIMEOUT"));
8547
8810
  this._responseActions.push(this._actionGreeting);
8548
8811
  socket.resume();
8549
8812
  }
8813
+ /**
8814
+ * Ends the session after a 421 reply. The replies queued for commands sent along with the
8815
+ * answered one are not going to come, so the message in flight is failed here
8816
+ *
8817
+ * @param str The 421 reply
8818
+ * @internal
8819
+ */
8820
+ _onServerClosing(str2) {
8821
+ if (this._destroyed) {
8822
+ return;
8823
+ }
8824
+ const pendingSend = this._pendingSend;
8825
+ const envelope = this._envelope;
8826
+ this._responseActions = [];
8827
+ this.close();
8828
+ if (pendingSend) {
8829
+ pendingSend.callback(envelope && envelope.mailError || this._formatError("Server closed the connection", "ECONNECTION", str2, "CONN"));
8830
+ }
8831
+ }
8550
8832
  /**
8551
8833
  * 'data' listener for data coming from the server
8552
8834
  *
@@ -8610,17 +8892,15 @@ var init_smtp_connection = __esm({
8610
8892
  * @internal
8611
8893
  */
8612
8894
  _onError(err, type, data, command) {
8613
- clearTimeout(this._connectionTimeout);
8614
- clearTimeout(this._greetingTimeout);
8895
+ this._clearPhase();
8615
8896
  if (this._destroyed) {
8616
8897
  return;
8617
8898
  }
8618
8899
  err = this._formatError(err, type, data, command);
8619
- const transientCodes = ["ETIMEDOUT", "ESOCKET", "ECONNECTION"];
8620
- if (transientCodes.includes(err.code)) {
8621
- this.logger.warn(data, err.message);
8900
+ if (isTransientError(err)) {
8901
+ this.logger.warn({ tnx: "smtp", err }, "%s", err.message);
8622
8902
  } else {
8623
- this.logger.error(data, err.message);
8903
+ this.logger.error({ tnx: "smtp", err }, "%s", err.message);
8624
8904
  }
8625
8905
  const pendingSend = this._pendingSend;
8626
8906
  this.emit("error", err);
@@ -8637,7 +8917,10 @@ var init_smtp_connection = __esm({
8637
8917
  } else {
8638
8918
  err = new Error(message);
8639
8919
  }
8640
- if (type && type !== "Error") {
8920
+ if (type && type !== "Error" && err.code !== ERR_ACCESS_DENIED) {
8921
+ if (err.code && err.code !== type && !err.originalCode) {
8922
+ err.originalCode = err.code;
8923
+ }
8641
8924
  err.code = type;
8642
8925
  }
8643
8926
  if (response) {
@@ -8685,6 +8968,12 @@ var init_smtp_connection = __esm({
8685
8968
  this.close();
8686
8969
  return;
8687
8970
  }
8971
+ if (!failureResponse && this.stage === "connected" && !this._responseActions.length && !this._pendingSend && !this._destroyed && !this._closing) {
8972
+ this.logger.info({
8973
+ tnx: "network"
8974
+ }, "Server closed the idle connection");
8975
+ return this._destroy();
8976
+ }
8688
8977
  if (failureResponse || this._responseActions[0] !== this.close && !this._destroyed) {
8689
8978
  return this._onError(new Error("Connection closed unexpectedly"), "ECONNECTION", failureResponse, "CONN");
8690
8979
  }
@@ -8708,7 +8997,7 @@ var init_smtp_connection = __esm({
8708
8997
  * @internal
8709
8998
  */
8710
8999
  _onTimeout() {
8711
- return this._onError(new Error("Timeout"), "ETIMEDOUT", false, "CONN");
9000
+ return this._onError(timeoutError("Timeout", "SOCKET_TIMEOUT"), "ETIMEDOUT", false, "CONN");
8712
9001
  }
8713
9002
  /**
8714
9003
  * Destroys the client, emits 'end'
@@ -8720,10 +9009,7 @@ var init_smtp_connection = __esm({
8720
9009
  }
8721
9010
  this._destroyed = true;
8722
9011
  this.destroyed = true;
8723
- clearTimeout(this._connectionTimeout);
8724
- clearTimeout(this._greetingTimeout);
8725
- this._connectionTimeout = false;
8726
- this._greetingTimeout = false;
9012
+ this._clearPhase();
8727
9013
  this.emit("end");
8728
9014
  }
8729
9015
  /**
@@ -8734,12 +9020,21 @@ var init_smtp_connection = __esm({
8734
9020
  * @internal
8735
9021
  */
8736
9022
  _upgradeConnection(callback) {
9023
+ const discarded = this._remainder.length + this._responseQueue.reduce((total, response) => total + response.length, 0);
9024
+ if (discarded) {
9025
+ this.logger.warn({
9026
+ tnx: "smtp",
9027
+ discarded
9028
+ }, "Discarded %s bytes received in plaintext after the STARTTLS response", discarded);
9029
+ }
9030
+ this._plaintextEhlo = false;
8737
9031
  this._remainder = "";
8738
9032
  this._responseQueue = [];
8739
9033
  this._responsePartial = false;
8740
9034
  const socketPlain = this._socket;
8741
9035
  socketPlain.removeListener("data", this._onSocketData);
8742
9036
  socketPlain.removeListener("timeout", this._onSocketTimeout);
9037
+ socketPlain.setTimeout(0);
8743
9038
  const opts = Object.assign({
8744
9039
  socket: socketPlain,
8745
9040
  host: this.host
@@ -8754,8 +9049,10 @@ var init_smtp_connection = __esm({
8754
9049
  socketPlain.removeListener("error", this._onConnectionSocketError);
8755
9050
  };
8756
9051
  this.upgrading = true;
9052
+ this._startPhase(this._remainingSetupTime(), timeoutError("TLS handshake timed out", "UPGRADE_TIMEOUT"));
8757
9053
  try {
8758
9054
  this._socket = tls2.connect(opts, () => {
9055
+ this._clearPhase();
8759
9056
  this.secure = true;
8760
9057
  this.upgrading = false;
8761
9058
  this._socket.on("data", this._onSocketData);
@@ -8763,6 +9060,7 @@ var init_smtp_connection = __esm({
8763
9060
  return callback(null, true);
8764
9061
  });
8765
9062
  } catch (err) {
9063
+ this._clearPhase();
8766
9064
  removePlainSocketListeners();
8767
9065
  return callback(err);
8768
9066
  }
@@ -8797,9 +9095,18 @@ var init_smtp_connection = __esm({
8797
9095
  }, str2.replace(/\r?\n$/, ""));
8798
9096
  }
8799
9097
  const action = this._responseActions.shift();
9098
+ const closing = /^421[ -]/.test(str2);
8800
9099
  if (typeof action === "function") {
8801
9100
  action.call(this, str2);
9101
+ if (closing) {
9102
+ return this._onServerClosing(str2);
9103
+ }
8802
9104
  setImmediate(() => this._processResponse());
9105
+ } else if (closing && !this._pendingSend && this.stage === "connected") {
9106
+ this.logger.info({
9107
+ tnx: "smtp"
9108
+ }, "Server closed the idle connection: %s", str2);
9109
+ this.close();
8803
9110
  } else {
8804
9111
  return this._onError(new Error("Unexpected Response"), "EPROTOCOL", str2, "CONN");
8805
9112
  }
@@ -8879,6 +9186,7 @@ var init_smtp_connection = __esm({
8879
9186
  return callback(this._formatError("Server does not support REQUIRETLS extension (RFC 8689)", "EREQUIRETLS", false, "MAIL FROM"));
8880
9187
  }
8881
9188
  }
9189
+ this._envelope.pipelined = this._supportedExtensions.includes("PIPELINING");
8882
9190
  this._responseActions.push((str2) => {
8883
9191
  this._actionMAIL(str2, callback);
8884
9192
  });
@@ -8907,7 +9215,37 @@ var init_smtp_connection = __esm({
8907
9215
  if (this._envelope.requireTLSExtensionEnabled) {
8908
9216
  args.push("REQUIRETLS");
8909
9217
  }
8910
- this._sendCommand("MAIL FROM:<" + this._envelope.from + ">" + (args.length ? " " + args.join(" ") : ""));
9218
+ const mailFrom = "MAIL FROM:<" + this._envelope.from + ">" + (args.length ? " " + args.join(" ") : "");
9219
+ this._recipientQueue = [];
9220
+ if (!this._envelope.pipelined) {
9221
+ this._sendCommand(mailFrom);
9222
+ return;
9223
+ }
9224
+ const socket = this._socket;
9225
+ socket.cork();
9226
+ this._sendCommand(mailFrom);
9227
+ while (this._envelope.rcptQueue.length) {
9228
+ this._sendRcpt(this._envelope.rcptQueue.shift(), callback);
9229
+ }
9230
+ this._responseActions.push((str2) => {
9231
+ this._actionDATA(str2, callback);
9232
+ });
9233
+ this._sendCommand("DATA");
9234
+ socket.uncork();
9235
+ }
9236
+ /**
9237
+ * Sends RCPT TO for a recipient and queues the handler for the reply
9238
+ *
9239
+ * @param recipient Recipient address
9240
+ * @param callback Callback to run once the envelope is processed
9241
+ * @internal
9242
+ */
9243
+ _sendRcpt(recipient, callback) {
9244
+ this._recipientQueue.push(recipient);
9245
+ this._responseActions.push((str2) => {
9246
+ this._actionRCPT(str2, callback);
9247
+ });
9248
+ this._sendCommand("RCPT TO:<" + recipient + ">" + this._getDsnRcptToArgs());
8911
9249
  }
8912
9250
  /** @internal */
8913
9251
  _setDsnEnvelope(params) {
@@ -9020,7 +9358,7 @@ var init_smtp_connection = __esm({
9020
9358
  * @internal
9021
9359
  */
9022
9360
  _actionGreeting(str2) {
9023
- clearTimeout(this._greetingTimeout);
9361
+ this._clearPhase();
9024
9362
  if (str2.substr(0, 3) !== "220") {
9025
9363
  this._onError(new Error("Invalid greeting. response=" + str2), "EPROTOCOL", str2, "CONN");
9026
9364
  return;
@@ -9057,7 +9395,6 @@ var init_smtp_connection = __esm({
9057
9395
  * @internal
9058
9396
  */
9059
9397
  _actionEHLO(str2) {
9060
- let match;
9061
9398
  if (str2.substr(0, 3) === "421") {
9062
9399
  this._onError(new Error("Server terminates connection. response=" + str2), "ECONNECTION", str2, "EHLO");
9063
9400
  return;
@@ -9071,12 +9408,24 @@ var init_smtp_connection = __esm({
9071
9408
  this._sendCommand("HELO " + this.name);
9072
9409
  return;
9073
9410
  }
9074
- this._ehloLines = str2.split(/\r?\n/).map((line) => line.replace(/^\d+[ -]/, "").trim()).filter((line) => line).slice(1);
9075
9411
  if (!this.secure && !this.options.ignoreTLS && (/[ -]STARTTLS\b/im.test(str2) || this.options.requireTLS)) {
9412
+ this._plaintextEhlo = str2;
9076
9413
  this._sendCommand("STARTTLS");
9077
9414
  this._responseActions.push(this._actionSTARTTLS);
9078
9415
  return;
9079
9416
  }
9417
+ this._parseEhloExtensions(str2);
9418
+ this.emit("connect");
9419
+ }
9420
+ /**
9421
+ * Reads the extensions and the authentication mechanisms out of an EHLO response
9422
+ *
9423
+ * @param str EHLO response from the server
9424
+ * @internal
9425
+ */
9426
+ _parseEhloExtensions(str2) {
9427
+ let match;
9428
+ this._ehloLines = str2.split(/\r?\n/).map((line) => line.replace(/^\d+[ -]/, "").trim()).filter((line) => line).slice(1);
9080
9429
  if (/[ -]SMTPUTF8\b/im.test(str2)) {
9081
9430
  this._supportedExtensions.push("SMTPUTF8");
9082
9431
  }
@@ -9113,7 +9462,6 @@ var init_smtp_connection = __esm({
9113
9462
  this._supportedExtensions.push("SIZE");
9114
9463
  this._maxAllowedSize = Number(match[1]) || 0;
9115
9464
  }
9116
- this.emit("connect");
9117
9465
  }
9118
9466
  /**
9119
9467
  * Handles server response for HELO command. If it yielded in
@@ -9144,6 +9492,12 @@ var init_smtp_connection = __esm({
9144
9492
  this.logger.info({
9145
9493
  tnx: "smtp"
9146
9494
  }, "Failed STARTTLS upgrade, continuing unencrypted");
9495
+ if (this._plaintextEhlo) {
9496
+ this._parseEhloExtensions(this._plaintextEhlo);
9497
+ this._plaintextEhlo = false;
9498
+ this.allowsAuth = false;
9499
+ this._supportedAuth = [];
9500
+ }
9147
9501
  this.emit("connect");
9148
9502
  return;
9149
9503
  }
@@ -9318,21 +9672,9 @@ var init_smtp_connection = __esm({
9318
9672
  const envelope = this._envelope;
9319
9673
  if (Number(str2.charAt(0)) !== 2) {
9320
9674
  const message = this._usingSmtpUtf8 && /^550 /.test(str2) && /[\x80-\uFFFF]/.test(envelope.from) ? "Internationalized mailbox name not allowed" : "Mail command failed";
9321
- return callback(this._formatError(message, "EENVELOPE", str2, "MAIL FROM"));
9675
+ envelope.mailError = this._formatError(message, "EENVELOPE", str2, "MAIL FROM");
9322
9676
  }
9323
- if (!envelope.rcptQueue.length) {
9324
- return callback(this._formatError("Can't send mail - no recipients defined", "EENVELOPE", false, "API"));
9325
- }
9326
- this._recipientQueue = [];
9327
- const usePipelining = this._supportedExtensions.includes("PIPELINING");
9328
- do {
9329
- const curRecipient = envelope.rcptQueue.shift();
9330
- this._recipientQueue.push(curRecipient);
9331
- this._responseActions.push((str3) => {
9332
- this._actionRCPT(str3, callback);
9333
- });
9334
- this._sendCommand("RCPT TO:<" + curRecipient + ">" + this._getDsnRcptToArgs());
9335
- } while (usePipelining && envelope.rcptQueue.length);
9677
+ this._advanceEnvelope(str2, callback);
9336
9678
  }
9337
9679
  /**
9338
9680
  * Handle response for a RCPT TO: command
@@ -9354,28 +9696,63 @@ var init_smtp_connection = __esm({
9354
9696
  } else {
9355
9697
  envelope.accepted.push(curRecipient);
9356
9698
  }
9357
- if (!envelope.rcptQueue.length && !this._recipientQueue.length) {
9358
- if (envelope.rejected.length < envelope.to.length) {
9359
- this._responseActions.push((str3) => {
9360
- this._actionDATA(str3, callback);
9361
- });
9362
- this._sendCommand("DATA");
9363
- } else {
9364
- const deferred = envelope.rejectedErrors.find((rejectedErr) => rejectedErr.responseCode && rejectedErr.responseCode < 500);
9365
- const reply = deferred?.response ?? str2;
9366
- err = this._formatError("Can't send mail - all recipients were rejected", "EENVELOPE", reply, "RCPT TO");
9367
- err.rejected = envelope.rejected;
9368
- err.rejectedErrors = envelope.rejectedErrors;
9369
- return callback(err);
9370
- }
9371
- } else if (envelope.rcptQueue.length) {
9372
- const nextRecipient = envelope.rcptQueue.shift();
9373
- this._recipientQueue.push(nextRecipient);
9374
- this._responseActions.push((str3) => {
9375
- this._actionRCPT(str3, callback);
9376
- });
9377
- this._sendCommand("RCPT TO:<" + nextRecipient + ">" + this._getDsnRcptToArgs());
9699
+ this._advanceEnvelope(str2, callback);
9700
+ }
9701
+ /**
9702
+ * Moves the envelope on after a reply to MAIL FROM or RCPT TO. A pipelined envelope sent every
9703
+ * command at once and is decided by the reply to DATA. Otherwise the commands go one at a
9704
+ * time: the next recipient, or once every reply is in, DATA or the error that ends the message
9705
+ *
9706
+ * @param str The reply that was handled
9707
+ * @param callback Callback to run once the envelope is processed
9708
+ * @internal
9709
+ */
9710
+ _advanceEnvelope(str2, callback) {
9711
+ const envelope = this._envelope;
9712
+ if (envelope.pipelined) {
9713
+ return;
9714
+ }
9715
+ if (envelope.mailError) {
9716
+ return callback(envelope.mailError);
9717
+ }
9718
+ if (envelope.rcptQueue.length) {
9719
+ return this._sendRcpt(envelope.rcptQueue.shift(), callback);
9720
+ }
9721
+ if (this._recipientQueue.length) {
9722
+ return;
9723
+ }
9724
+ const err = this._envelopeError(str2);
9725
+ if (err) {
9726
+ return callback(err);
9727
+ }
9728
+ this._responseActions.push((str3) => {
9729
+ this._actionDATA(str3, callback);
9730
+ });
9731
+ this._sendCommand("DATA");
9732
+ }
9733
+ /**
9734
+ * Decides how the envelope went once every reply to MAIL FROM and RCPT TO is in. Called after
9735
+ * the last RCPT TO reply, or with PIPELINING on the reply to the DATA command sent along
9736
+ *
9737
+ * @param str The reply being handled
9738
+ * @returns The error to fail the message with, or null when DATA can go ahead
9739
+ * @internal
9740
+ */
9741
+ _envelopeError(str2) {
9742
+ const envelope = this._envelope;
9743
+ if (envelope.mailError) {
9744
+ return envelope.mailError;
9745
+ }
9746
+ if (envelope.accepted.length) {
9747
+ return null;
9378
9748
  }
9749
+ const deferred = envelope.rejectedErrors.find((rejectedErr) => rejectedErr.responseCode && rejectedErr.responseCode < 500);
9750
+ const lastRejected = envelope.rejectedErrors[envelope.rejectedErrors.length - 1];
9751
+ const reply = deferred?.response ?? (envelope.pipelined && lastRejected ? lastRejected.response : str2);
9752
+ const err = this._formatError("Can't send mail - all recipients were rejected", "EENVELOPE", reply, "RCPT TO");
9753
+ err.rejected = envelope.rejected;
9754
+ err.rejectedErrors = envelope.rejectedErrors;
9755
+ return err;
9379
9756
  }
9380
9757
  /**
9381
9758
  * Handle response for a DATA command
@@ -9386,6 +9763,21 @@ var init_smtp_connection = __esm({
9386
9763
  */
9387
9764
  _actionDATA(str2, callback) {
9388
9765
  const envelope = this._envelope;
9766
+ if (envelope.pipelined) {
9767
+ const err = this._envelopeError(str2);
9768
+ if (err) {
9769
+ if (/^3/.test(str2)) {
9770
+ if (envelope.mailError) {
9771
+ this.close();
9772
+ return callback(err);
9773
+ }
9774
+ this._responseActions.push(() => callback(err));
9775
+ this._sendCommand(".");
9776
+ return;
9777
+ }
9778
+ return callback(err);
9779
+ }
9780
+ }
9389
9781
  if (!/^[23]/.test(str2)) {
9390
9782
  return callback(this._formatError("Data command failed", "EENVELOPE", str2, "DATA"));
9391
9783
  }
@@ -9505,12 +9897,12 @@ var init_smtp_connection = __esm({
9505
9897
  }
9506
9898
  });
9507
9899
 
9508
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/xoauth2/index.js
9900
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/xoauth2/index.js
9509
9901
  import { Stream } from "node:stream";
9510
9902
  import crypto7 from "node:crypto";
9511
9903
  var XOAuth2, xoauth2_default;
9512
9904
  var init_xoauth2 = __esm({
9513
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/xoauth2/index.js"() {
9905
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/xoauth2/index.js"() {
9514
9906
  init_fetch();
9515
9907
  init_shared();
9516
9908
  init_errors();
@@ -9840,11 +10232,11 @@ var init_xoauth2 = __esm({
9840
10232
  }
9841
10233
  });
9842
10234
 
9843
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/smtp-pool/pool-resource.js
10235
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/smtp-pool/pool-resource.js
9844
10236
  import { EventEmitter as EventEmitter3 } from "node:events";
9845
10237
  var PoolResource;
9846
10238
  var init_pool_resource = __esm({
9847
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/smtp-pool/pool-resource.js"() {
10239
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/smtp-pool/pool-resource.js"() {
9848
10240
  init_smtp_connection();
9849
10241
  init_shared();
9850
10242
  init_xoauth2();
@@ -9891,6 +10283,8 @@ var init_pool_resource = __esm({
9891
10283
  this.messages = 0;
9892
10284
  this.available = true;
9893
10285
  this._failed = false;
10286
+ this._sending = false;
10287
+ this._idleTimer = false;
9894
10288
  }
9895
10289
  /**
9896
10290
  * Emits 'error' for the first failure only. A dead resource can report the same failure more
@@ -9910,7 +10304,8 @@ var init_pool_resource = __esm({
9910
10304
  * @param callback Callback function to run once the connection is established or failed
9911
10305
  */
9912
10306
  connect(callback) {
9913
- this.pool.getSocket(this.options, (err, socketOptions) => {
10307
+ const connectStartedAt = Date.now();
10308
+ this.pool.getSocket(Object.assign({}, this.options, { connectStartedAt }), (err, socketOptions) => {
9914
10309
  if (err) {
9915
10310
  this._fail(err);
9916
10311
  return callback(err);
@@ -9929,7 +10324,18 @@ var init_pool_resource = __esm({
9929
10324
  options = Object.assign(assign(false, options), socketOptions);
9930
10325
  }
9931
10326
  this.connection = new smtp_connection_default(options);
10327
+ this.connection._connectStartedAt = connectStartedAt;
9932
10328
  this.connection.on("error", (err2) => {
10329
+ if (this._sending) {
10330
+ return;
10331
+ }
10332
+ if (this._connected && isTransientError(err2)) {
10333
+ this.logger.info({
10334
+ tnx: "pool",
10335
+ cid: this.id
10336
+ }, "Connection #%s was closed by the server: %s", this.id, err2.message);
10337
+ return;
10338
+ }
9933
10339
  this._fail(err2);
9934
10340
  if (returned) {
9935
10341
  return;
@@ -10003,9 +10409,32 @@ var init_pool_resource = __esm({
10003
10409
  if (mail.data.requireTLSExtensionEnabled) {
10004
10410
  envelope.requireTLSExtensionEnabled = mail.data.requireTLSExtensionEnabled;
10005
10411
  }
10006
- this.connection.send(envelope, mail.message.createReadStream(), (err, info) => {
10412
+ this._sending = true;
10413
+ const reused = this.messages > 0;
10414
+ const messageStream = mail.message.createReadStream();
10415
+ this.connection.send(envelope, messageStream, (err, info) => {
10416
+ this._sending = false;
10007
10417
  this.messages++;
10008
10418
  if (err) {
10419
+ if (reused && messageStream.readableDidRead === false && isTransientError(err)) {
10420
+ this.logger.info({
10421
+ tnx: "pool",
10422
+ cid: this.id,
10423
+ messageId
10424
+ }, "Connection #%s was closed by the server before message %s was sent: %s", this.id, messageId, err.message);
10425
+ this.connection.close();
10426
+ return;
10427
+ }
10428
+ if ((err.code === EENVELOPE || err.code === EMESSAGE) && err.responseCode !== 421 && !this.connection._destroyed) {
10429
+ this.connection.reset((resetErr) => {
10430
+ if (resetErr) {
10431
+ this.connection.close();
10432
+ return;
10433
+ }
10434
+ this._release();
10435
+ });
10436
+ return callback(err);
10437
+ }
10009
10438
  this.connection.close();
10010
10439
  this._fail(err);
10011
10440
  return callback(err);
@@ -10015,27 +10444,66 @@ var init_pool_resource = __esm({
10015
10444
  to: envelope.to
10016
10445
  };
10017
10446
  info.messageId = messageId;
10018
- setImmediate(() => {
10019
- if (this.messages >= this.options.maxMessages) {
10020
- const err2 = new Error("Resource exhausted");
10021
- err2.code = EMAXLIMIT;
10022
- this.connection.close();
10023
- this._fail(err2);
10024
- } else {
10025
- this.pool._checkRateLimit(() => {
10026
- this.available = true;
10027
- this.emit("available");
10028
- });
10029
- }
10030
- });
10447
+ setImmediate(() => this._release());
10031
10448
  callback(null, info);
10032
10449
  });
10033
10450
  }
10451
+ /**
10452
+ * Makes the connection available for the next message, or closes it once it has sent
10453
+ * maxMessages messages
10454
+ *
10455
+ * @internal
10456
+ */
10457
+ _release() {
10458
+ if (this.messages >= this.options.maxMessages) {
10459
+ const err = new Error("Resource exhausted");
10460
+ err.code = EMAXLIMIT;
10461
+ this.connection.close();
10462
+ this._fail(err);
10463
+ return;
10464
+ }
10465
+ this.pool._checkRateLimit(() => {
10466
+ this.available = true;
10467
+ this._startIdleTimer();
10468
+ this.emit("available");
10469
+ });
10470
+ }
10471
+ /** @internal */
10472
+ _startIdleTimer() {
10473
+ if (!this.options.idleTimeout || this.options.idleTimeout < 0) {
10474
+ return;
10475
+ }
10476
+ if (this._idleTimer && typeof this._idleTimer.refresh === "function") {
10477
+ this._idleTimer.refresh();
10478
+ return;
10479
+ }
10480
+ clearTimeout(this._idleTimer);
10481
+ this._idleTimer = setTimeout(() => {
10482
+ if (!this.available) {
10483
+ return;
10484
+ }
10485
+ this.logger.debug({
10486
+ tnx: "pool",
10487
+ cid: this.id
10488
+ }, "Closing connection #%s after it was idle for %sms", this.id, this.options.idleTimeout);
10489
+ this.available = false;
10490
+ this.connection.quit();
10491
+ }, this.options.idleTimeout);
10492
+ if (typeof this._idleTimer.unref === "function") {
10493
+ this._idleTimer.unref();
10494
+ }
10495
+ }
10496
+ /** @internal */
10497
+ _stopIdleTimer() {
10498
+ clearTimeout(this._idleTimer);
10499
+ this._idleTimer = false;
10500
+ }
10034
10501
  /**
10035
10502
  * Closes the connection
10036
10503
  */
10037
10504
  close() {
10038
10505
  this._connected = false;
10506
+ this._stopIdleTimer();
10039
10507
  if (this.auth && this.auth.oauth2) {
10040
10508
  this.auth.oauth2.removeAllListeners();
10041
10509
  }
@@ -10048,10 +10516,10 @@ var init_pool_resource = __esm({
10048
10516
  }
10049
10517
  });
10050
10518
 
10051
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/well-known/services.js
10519
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/well-known/services.js
10052
10520
  var services;
10053
10521
  var init_services = __esm({
10054
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/well-known/services.js"() {
10522
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/well-known/services.js"() {
10055
10523
  services = {
10056
10524
  "126": {
10057
10525
  "description": "126 Mail (NetEase)",
@@ -10725,7 +11193,7 @@ var init_services = __esm({
10725
11193
  }
10726
11194
  });
10727
11195
 
10728
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/well-known/index.js
11196
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/well-known/index.js
10729
11197
  function normalizeKey(key) {
10730
11198
  return key.replace(/[^a-zA-Z0-9.-]/g, "").toLowerCase();
10731
11199
  }
@@ -10744,7 +11212,7 @@ function wellKnown(key) {
10744
11212
  }
10745
11213
  var normalized;
10746
11214
  var init_well_known = __esm({
10747
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/well-known/index.js"() {
11215
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/well-known/index.js"() {
10748
11216
  init_services();
10749
11217
  normalized = {};
10750
11218
  Object.keys(services).forEach((key) => {
@@ -10761,11 +11229,11 @@ var init_well_known = __esm({
10761
11229
  }
10762
11230
  });
10763
11231
 
10764
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/smtp-pool/index.js
11232
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/smtp-pool/index.js
10765
11233
  import { EventEmitter as EventEmitter4 } from "node:events";
10766
11234
  var REQUEUE_BASE_DELAY, REQUEUE_MAX_DELAY, SMTPPool, smtp_pool_default;
10767
11235
  var init_smtp_pool = __esm({
10768
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/smtp-pool/index.js"() {
11236
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/smtp-pool/index.js"() {
10769
11237
  init_pool_resource();
10770
11238
  init_smtp_connection();
10771
11239
  init_well_known();
@@ -10805,6 +11273,7 @@ var init_smtp_pool = __esm({
10805
11273
  this.options.maxConnections = this.options.maxConnections || 5;
10806
11274
  this.options.maxMessages = this.options.maxMessages || 100;
10807
11275
  this.options.maxRequeues = typeof this.options.maxRequeues === "number" ? this.options.maxRequeues : 5;
11276
+ this.options.idleTimeout = typeof this.options.idleTimeout === "number" ? this.options.idleTimeout : 4 * 60 * 1e3;
10808
11277
  this.logger = getLogger(this.options, {
10809
11278
  component: this.options.component || "smtp-pool"
10810
11279
  });
@@ -11174,7 +11643,8 @@ var init_smtp_pool = __esm({
11174
11643
  }
11175
11644
  const done = callback;
11176
11645
  const auth = new PoolResource(this).auth;
11177
- this.getSocket(this.options, (err, socketOptions) => {
11646
+ const connectStartedAt = Date.now();
11647
+ this.getSocket(Object.assign({}, this.options, { connectStartedAt }), (err, socketOptions) => {
11178
11648
  if (err) {
11179
11649
  return done(err);
11180
11650
  }
@@ -11191,6 +11661,7 @@ var init_smtp_pool = __esm({
11191
11661
  options = Object.assign(assign(false, options), socketOptions);
11192
11662
  }
11193
11663
  const connection = new smtp_connection_default(options);
11664
+ connection._connectStartedAt = connectStartedAt;
11194
11665
  let returned = false;
11195
11666
  connection.once("error", (err2) => {
11196
11667
  if (returned) {
@@ -11254,11 +11725,11 @@ var init_smtp_pool = __esm({
11254
11725
  }
11255
11726
  });
11256
11727
 
11257
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/smtp-transport/index.js
11728
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/smtp-transport/index.js
11258
11729
  import { EventEmitter as EventEmitter5 } from "node:events";
11259
11730
  var SMTPTransport, smtp_transport_default;
11260
11731
  var init_smtp_transport = __esm({
11261
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/smtp-transport/index.js"() {
11732
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/smtp-transport/index.js"() {
11262
11733
  init_smtp_connection();
11263
11734
  init_well_known();
11264
11735
  init_shared();
@@ -11359,7 +11830,8 @@ var init_smtp_transport = __esm({
11359
11830
  * @param callback Callback function
11360
11831
  */
11361
11832
  send(mail, callback) {
11362
- this.getSocket(this.options, (err, socketOptions) => {
11833
+ const connectStartedAt = Date.now();
11834
+ this.getSocket(Object.assign({}, this.options, { connectStartedAt }), (err, socketOptions) => {
11363
11835
  if (err) {
11364
11836
  return callback(err);
11365
11837
  }
@@ -11377,6 +11849,7 @@ var init_smtp_transport = __esm({
11377
11849
  options = Object.assign(assign(false, options), socketOptions);
11378
11850
  }
11379
11851
  const connection = new smtp_connection_default(options);
11852
+ connection._connectStartedAt = connectStartedAt;
11380
11853
  let perCallAuth;
11381
11854
  const cleanupPerCallAuth = () => {
11382
11855
  if (perCallAuth && perCallAuth !== this.auth && perCallAuth.oauth2) {
@@ -11476,7 +11949,8 @@ var init_smtp_transport = __esm({
11476
11949
  });
11477
11950
  }
11478
11951
  const done = callback;
11479
- this.getSocket(this.options, (err, socketOptions) => {
11952
+ const connectStartedAt = Date.now();
11953
+ this.getSocket(Object.assign({}, this.options, { connectStartedAt }), (err, socketOptions) => {
11480
11954
  if (err) {
11481
11955
  return done(err);
11482
11956
  }
@@ -11493,6 +11967,7 @@ var init_smtp_transport = __esm({
11493
11967
  options = Object.assign(assign(false, options), socketOptions);
11494
11968
  }
11495
11969
  const connection = new smtp_connection_default(options);
11970
+ connection._connectStartedAt = connectStartedAt;
11496
11971
  let returned = false;
11497
11972
  let perCallAuth;
11498
11973
  const cleanupPerCallAuth = () => {
@@ -11578,16 +12053,18 @@ var init_smtp_transport = __esm({
11578
12053
  }
11579
12054
  });
11580
12055
 
11581
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/sendmail-transport/index.js
12056
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/sendmail-transport/index.js
11582
12057
  import { spawn } from "node:child_process";
11583
- var SendmailTransport, sendmail_transport_default;
12058
+ import { pipeline as pipeline2 } from "node:stream";
12059
+ var STDIN_ERROR_EXIT_WAIT, SendmailTransport, sendmail_transport_default;
11584
12060
  var init_sendmail_transport = __esm({
11585
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/sendmail-transport/index.js"() {
12061
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/sendmail-transport/index.js"() {
11586
12062
  init_package_info();
11587
12063
  init_shared();
11588
12064
  init_errors();
11589
12065
  init_le_windows();
11590
12066
  init_le_unix();
12067
+ STDIN_ERROR_EXIT_WAIT = 1e3;
11591
12068
  SendmailTransport = class {
11592
12069
  constructor(options) {
11593
12070
  options = options || {};
@@ -11658,35 +12135,63 @@ var init_sendmail_transport = __esm({
11658
12135
  return callback(E);
11659
12136
  }
11660
12137
  if (sendmail) {
12138
+ let stream;
12139
+ const messageWritten = () => !!stream && stream.readableEnded;
12140
+ let stdinError = null;
12141
+ const release = () => {
12142
+ if (stream && !messageWritten()) {
12143
+ stream.destroy();
12144
+ }
12145
+ };
12146
+ const fail = (err) => {
12147
+ release();
12148
+ callback(err);
12149
+ };
11661
12150
  sendmail.on("error", (err) => {
11662
12151
  this.logger.error({
11663
12152
  err,
11664
12153
  tnx: "spawn",
11665
12154
  messageId
11666
12155
  }, "Error occurred when sending message %s. %s", messageId, err.message);
11667
- callback(err);
12156
+ fail(err);
11668
12157
  });
11669
- sendmail.once("exit", (code) => {
11670
- if (!code) {
12158
+ const onExit = (code, signal) => {
12159
+ let err = null;
12160
+ if (code) {
12161
+ err = new Error(code === 127 ? "Sendmail command not found, process exited with code " + code : "Sendmail exited with code " + code);
12162
+ } else if (signal) {
12163
+ err = new Error("Sendmail was terminated by " + signal);
12164
+ } else if (!messageWritten()) {
12165
+ err = new Error("Sendmail exited before the message was written");
12166
+ } else if (stdinError) {
12167
+ err = stdinError;
12168
+ }
12169
+ if (!err) {
11671
12170
  return callback();
11672
12171
  }
11673
- const err = new Error(code === 127 ? "Sendmail command not found, process exited with code " + code : "Sendmail exited with code " + code);
11674
- err.code = ESENDMAIL;
12172
+ err.code = err.code || ESENDMAIL;
11675
12173
  this.logger.error({
11676
12174
  err,
11677
12175
  tnx: "stdin",
11678
12176
  messageId
11679
12177
  }, "Error sending message %s to sendmail. %s", messageId, err.message);
11680
- callback(err);
11681
- });
11682
- sendmail.once("close", callback);
12178
+ fail(err);
12179
+ };
12180
+ sendmail.once("exit", onExit);
12181
+ sendmail.once("close", onExit);
11683
12182
  sendmail.stdin.on("error", (err) => {
11684
12183
  this.logger.error({
11685
12184
  err,
11686
12185
  tnx: "stdin",
11687
12186
  messageId
11688
12187
  }, "Error occurred when piping message %s to sendmail. %s", messageId, err.message);
11689
- callback(err);
12188
+ if (stdinError) {
12189
+ return;
12190
+ }
12191
+ stdinError = err;
12192
+ release();
12193
+ const exitTimer = setTimeout(() => fail(err), STDIN_ERROR_EXIT_WAIT);
12194
+ sendmail.once("exit", () => clearTimeout(exitTimer));
11690
12195
  });
11691
12196
  const recipients = [].concat(envelope.to || []);
11692
12197
  if (recipients.length > 3) {
@@ -11697,10 +12202,9 @@ var init_sendmail_transport = __esm({
11697
12202
  messageId
11698
12203
  }, "Sending message %s to <%s>", messageId, recipients.join(", "));
11699
12204
  const sourceStream = mail.message.createReadStream();
11700
- let stream = sourceStream;
12205
+ stream = sourceStream;
11701
12206
  if (this.options.newline) {
11702
- stream = sourceStream.pipe(this.winbreak ? new LeWindows() : new LeUnix());
11703
- sourceStream.once("error", (err) => stream.emit("error", err));
12207
+ stream = pipeline2(sourceStream, this.winbreak ? new LeWindows() : new LeUnix(), () => false);
11704
12208
  }
11705
12209
  stream.once("error", (err) => {
11706
12210
  this.logger.error({
@@ -11723,10 +12227,10 @@ var init_sendmail_transport = __esm({
11723
12227
  }
11724
12228
  });
11725
12229
 
11726
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/stream-transport/index.js
12230
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/stream-transport/index.js
11727
12231
  var StreamTransport, stream_transport_default;
11728
12232
  var init_stream_transport = __esm({
11729
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/stream-transport/index.js"() {
12233
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/stream-transport/index.js"() {
11730
12234
  init_package_info();
11731
12235
  init_shared();
11732
12236
  init_le_windows();
@@ -11820,10 +12324,10 @@ var init_stream_transport = __esm({
11820
12324
  }
11821
12325
  });
11822
12326
 
11823
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/json-transport/index.js
12327
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/json-transport/index.js
11824
12328
  var JSONTransport, json_transport_default;
11825
12329
  var init_json_transport = __esm({
11826
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/json-transport/index.js"() {
12330
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/json-transport/index.js"() {
11827
12331
  init_package_info();
11828
12332
  init_shared();
11829
12333
  JSONTransport = class {
@@ -11879,7 +12383,7 @@ var init_json_transport = __esm({
11879
12383
  }
11880
12384
  });
11881
12385
 
11882
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/ses-transport/index.js
12386
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/ses-transport/index.js
11883
12387
  import EventEmitter6 from "node:events";
11884
12388
  function tagSesError(err) {
11885
12389
  if (err && typeof err === "object" && !err.code) {
@@ -11889,7 +12393,7 @@ function tagSesError(err) {
11889
12393
  }
11890
12394
  var SESTransport, ses_transport_default;
11891
12395
  var init_ses_transport = __esm({
11892
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/ses-transport/index.js"() {
12396
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/ses-transport/index.js"() {
11893
12397
  init_package_info();
11894
12398
  init_shared();
11895
12399
  init_errors();
@@ -12071,7 +12575,7 @@ var init_ses_transport = __esm({
12071
12575
  }
12072
12576
  });
12073
12577
 
12074
- // node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/nodemailer.js
12578
+ // node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/nodemailer.js
12075
12579
  function createTransport(transporter, defaults) {
12076
12580
  let options;
12077
12581
  if (
@@ -12120,11 +12624,11 @@ function createTestAccount(apiUrl, callback) {
12120
12624
  });
12121
12625
  }
12122
12626
  const done = callback;
12123
- if (ETHEREAL_CACHE && testAccount) {
12627
+ if (etherealCache() && testAccount) {
12124
12628
  setImmediate(() => done(null, testAccount));
12125
12629
  return promise;
12126
12630
  }
12127
- apiUrl = apiUrl || ETHEREAL_API;
12631
+ apiUrl = apiUrl || etherealApi();
12128
12632
  const chunks = [];
12129
12633
  let chunklen = 0;
12130
12634
  const requestHeaders = {};
@@ -12132,8 +12636,9 @@ function createTestAccount(apiUrl, callback) {
12132
12636
  requestor: name,
12133
12637
  version
12134
12638
  };
12135
- if (ETHEREAL_API_KEY) {
12136
- requestHeaders.Authorization = "Bearer " + ETHEREAL_API_KEY;
12639
+ const apiKey = etherealApiKey();
12640
+ if (apiKey) {
12641
+ requestHeaders.Authorization = "Bearer " + apiKey;
12137
12642
  }
12138
12643
  const fetchOptions = {
12139
12644
  contentType: "application/json",
@@ -12187,13 +12692,13 @@ function getTestMessageUrl(info) {
12187
12692
  }
12188
12693
  }
12189
12694
  if (infoProps.has("STATUS") && infoProps.has("MSGID")) {
12190
- return (testAccount && testAccount.web || ETHEREAL_WEB) + "/message/" + infoProps.get("MSGID");
12695
+ return (testAccount && testAccount.web || etherealWeb()) + "/message/" + infoProps.get("MSGID");
12191
12696
  }
12192
12697
  return false;
12193
12698
  }
12194
- var ETHEREAL_API, ETHEREAL_WEB, ETHEREAL_API_KEY, ETHEREAL_CACHE, testAccount, nodemailer, nodemailer_default;
12699
+ var etherealApi, etherealWeb, etherealApiKey, etherealCache, testAccount, nodemailer, nodemailer_default;
12195
12700
  var init_nodemailer = __esm({
12196
- "node_modules/.pnpm/nodemailer@10.0.16/node_modules/nodemailer/dist/esm/nodemailer.js"() {
12701
+ "node_modules/.pnpm/nodemailer@10.1.1/node_modules/nodemailer/dist/esm/nodemailer.js"() {
12197
12702
  init_mailer();
12198
12703
  init_shared();
12199
12704
  init_smtp_pool();
@@ -12205,10 +12710,10 @@ var init_nodemailer = __esm({
12205
12710
  init_errors();
12206
12711
  init_fetch();
12207
12712
  init_package_info();
12208
- ETHEREAL_API = (process.env.ETHEREAL_API || "https://api.nodemailer.com").replace(/\/+$/, "");
12209
- ETHEREAL_WEB = (process.env.ETHEREAL_WEB || "https://ethereal.email").replace(/\/+$/, "");
12210
- ETHEREAL_API_KEY = (process.env.ETHEREAL_API_KEY || "").replace(/\s*/g, "") || null;
12211
- ETHEREAL_CACHE = ["true", "yes", "y", "1"].includes((process.env.ETHEREAL_CACHE || "yes").toString().trim().toLowerCase());
12713
+ etherealApi = () => (process.env.ETHEREAL_API || "https://api.nodemailer.com").replace(/\/+$/, "");
12714
+ etherealWeb = () => (process.env.ETHEREAL_WEB || "https://ethereal.email").replace(/\/+$/, "");
12715
+ etherealApiKey = () => (process.env.ETHEREAL_API_KEY || "").replace(/\s*/g, "") || null;
12716
+ etherealCache = () => ["true", "yes", "y", "1"].includes((process.env.ETHEREAL_CACHE || "yes").toString().trim().toLowerCase());
12212
12717
  testAccount = false;
12213
12718
  nodemailer = {
12214
12719
  createTransport,
@@ -15090,7 +15595,7 @@ var require_transport = __commonJS({
15090
15595
  stream.flushSync();
15091
15596
  }
15092
15597
  function transport(fullOptions) {
15093
- const { pipeline, targets, levels, dedupe, worker = {}, caller = getCallers(), sync = false } = fullOptions;
15598
+ const { pipeline: pipeline3, targets, levels, dedupe, worker = {}, caller = getCallers(), sync = false } = fullOptions;
15094
15599
  const options = {
15095
15600
  ...fullOptions.options
15096
15601
  };
@@ -15118,9 +15623,9 @@ var require_transport = __commonJS({
15118
15623
  };
15119
15624
  });
15120
15625
  });
15121
- } else if (pipeline) {
15626
+ } else if (pipeline3) {
15122
15627
  target = bundlerOverrides["pino-worker"] || join2(__dirname, "worker.js");
15123
- options.pipelines = [pipeline.map((dest) => {
15628
+ options.pipelines = [pipeline3.map((dest) => {
15124
15629
  return {
15125
15630
  ...dest,
15126
15631
  target: fixTarget(dest.target)
@@ -15134,7 +15639,7 @@ var require_transport = __commonJS({
15134
15639
  options.dedupe = dedupe;
15135
15640
  }
15136
15641
  options.pinoWillSendConfig = true;
15137
- const name2 = targets || pipeline ? "pino.transport" : target;
15642
+ const name2 = targets || pipeline3 ? "pino.transport" : target;
15138
15643
  return buildStream(fixTarget(target), options, worker, sync, name2);
15139
15644
  function fixTarget(origin) {
15140
15645
  origin = bundlerOverrides[origin] || origin;
@@ -37613,7 +38118,7 @@ var require_libbase64 = __commonJS({
37613
38118
  str2 = str2 || "";
37614
38119
  return Buffer2.from(str2, "base64");
37615
38120
  }
37616
- function wrap3(str2, lineLength) {
38121
+ function wrap2(str2, lineLength) {
37617
38122
  str2 = (str2 || "").toString();
37618
38123
  lineLength = lineLength || 76;
37619
38124
  if (str2.length <= lineLength) {
@@ -37664,7 +38169,7 @@ var require_libbase64 = __commonJS({
37664
38169
  this.push(chunk);
37665
38170
  }
37666
38171
  _getWrapped(str2, isFinal) {
37667
- str2 = wrap3(str2, this.options.lineLength);
38172
+ str2 = wrap2(str2, this.options.lineLength);
37668
38173
  if (!isFinal && str2.length === this.options.lineLength) {
37669
38174
  str2 += "\r\n";
37670
38175
  }
@@ -37764,7 +38269,7 @@ var require_libbase64 = __commonJS({
37764
38269
  module.exports = {
37765
38270
  encode: encode4,
37766
38271
  decode: decode2,
37767
- wrap: wrap3,
38272
+ wrap: wrap2,
37768
38273
  Encoder: Encoder3,
37769
38274
  Decoder
37770
38275
  };
@@ -37821,7 +38326,7 @@ var require_libqp = __commonJS({
37821
38326
  }
37822
38327
  return buffer;
37823
38328
  }
37824
- function wrap3(str2, lineLength) {
38329
+ function wrap2(str2, lineLength) {
37825
38330
  str2 = (str2 || "").toString();
37826
38331
  lineLength = lineLength || 76;
37827
38332
  if (str2.length <= lineLength) {
@@ -37914,7 +38419,7 @@ var require_libqp = __commonJS({
37914
38419
  this.inputBytes += chunk.length;
37915
38420
  if (this.options.lineLength) {
37916
38421
  qp = this._curLine + encode4(chunk);
37917
- qp = wrap3(qp, this.options.lineLength);
38422
+ qp = wrap2(qp, this.options.lineLength);
37918
38423
  qp = qp.replace(/(^|\n)([^\n]*)$/, (match, lineBreak, lastLine) => {
37919
38424
  this._curLine = lastLine;
37920
38425
  return lineBreak;
@@ -37971,7 +38476,7 @@ var require_libqp = __commonJS({
37971
38476
  module.exports = {
37972
38477
  encode: encode4,
37973
38478
  decode: decode2,
37974
- wrap: wrap3,
38479
+ wrap: wrap2,
37975
38480
  Encoder: Encoder3,
37976
38481
  Decoder
37977
38482
  };
@@ -56879,7 +57384,7 @@ var require_imap_flow = __commonJS({
56879
57384
  if (!range) {
56880
57385
  return false;
56881
57386
  }
56882
- let finished = false;
57387
+ let finished3 = false;
56883
57388
  let aborted = false;
56884
57389
  let push = false;
56885
57390
  let rowQueue = [];
@@ -56892,7 +57397,7 @@ var require_imap_flow = __commonJS({
56892
57397
  }
56893
57398
  return resolve4(entry.value);
56894
57399
  }
56895
- if (finished) {
57400
+ if (finished3) {
56896
57401
  return resolve4(null);
56897
57402
  }
56898
57403
  push = () => {
@@ -56922,7 +57427,7 @@ var require_imap_flow = __commonJS({
56922
57427
  }
56923
57428
  }
56924
57429
  }).then(() => {
56925
- finished = true;
57430
+ finished3 = true;
56926
57431
  if (typeof push === "function") {
56927
57432
  push();
56928
57433
  }