@bobfrankston/mailx-imap 0.1.121 → 0.1.124

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 (2) hide show
  1. package/index.js +32 -7
  2. package/package.json +7 -7
package/index.js CHANGED
@@ -5226,12 +5226,27 @@ export class ImapManager extends EventEmitter {
5226
5226
  auth = { method: "XOAUTH2", user: smtpUser, token };
5227
5227
  }
5228
5228
  const parseAddrs = (s) => s.match(/[\w.+-]+@[\w.-]+/g) || [];
5229
- const toMatch = raw.match(/^To:\s*(.+)$/mi);
5230
- const ccMatch = raw.match(/^Cc:\s*(.+)$/mi);
5231
- const bccMatch = raw.match(/^Bcc:\s*(.+)$/mi);
5232
- const fromMatch = raw.match(/^From:\s*(.+)$/mi);
5233
- const subjectMatch = raw.match(/^Subject:\s*(.+)$/mi);
5234
- const messageIdMatch = raw.match(/^Message-ID:\s*(<[^>]+>)/mi);
5229
+ // Parse recipients from the HEADER SECTION only — never the body.
5230
+ // `/^Cc:/m` over the whole raw file matched header-looking lines in
5231
+ // the QUOTED REPLY CHAIN: a reply whose real headers had no Cc
5232
+ // picked up the quoted message's Cc, silently adding its addresses
5233
+ // to RCPT TO — one stranger got a copy, and a quoted-printable
5234
+ // soft-wrap truncated another mid-domain ("bworobey@gmail=" →
5235
+ // envelope bworobey@gmail → receiving qmail padded its default
5236
+ // domain → bounce; Bob 2026-07-21 "I didn't see him in the To
5237
+ // list"). Headers end at the first blank line. Folded continuation
5238
+ // lines are unfolded first, which ALSO fixes the old single-line
5239
+ // regex silently dropping every recipient after the first fold of
5240
+ // a long To: list.
5241
+ const headerEnd = raw.search(/\r?\n\r?\n/);
5242
+ const headerSec = (headerEnd === -1 ? raw : raw.slice(0, headerEnd))
5243
+ .replace(/\r?\n[ \t]+/g, " ");
5244
+ const toMatch = headerSec.match(/^To:\s*(.+)$/mi);
5245
+ const ccMatch = headerSec.match(/^Cc:\s*(.+)$/mi);
5246
+ const bccMatch = headerSec.match(/^Bcc:\s*(.+)$/mi);
5247
+ const fromMatch = headerSec.match(/^From:\s*(.+)$/mi);
5248
+ const subjectMatch = headerSec.match(/^Subject:\s*(.+)$/mi);
5249
+ const messageIdMatch = headerSec.match(/^Message-ID:\s*(<[^>]+>)/mi);
5235
5250
  const recipients = [
5236
5251
  ...(toMatch ? parseAddrs(toMatch[1]) : []),
5237
5252
  ...(ccMatch ? parseAddrs(ccMatch[1]) : []),
@@ -5256,7 +5271,17 @@ export class ImapManager extends EventEmitter {
5256
5271
  console.log(` [smtp] ${accountId}: SKIP ${messageId} — already in sent_log`);
5257
5272
  return;
5258
5273
  }
5259
- const rawToSend = raw.replace(/^Bcc:.*\r?\n/mi, "");
5274
+ // Strip Bcc from the transmitted copy — HEADER SECTION only (the
5275
+ // old whole-file replace could eat a "Bcc:"-looking line from the
5276
+ // quoted body instead, leaving the real Bcc visible to every
5277
+ // recipient). Folded continuation lines go with it. Recompute the
5278
+ // header boundary: the Message-ID synthesis above may have grown
5279
+ // the header section since headerSec was derived.
5280
+ const bccHdrEnd = raw.search(/\r?\n\r?\n/);
5281
+ const stripBcc = (h) => h.replace(/^Bcc:[^\n]*(\r?\n[ \t][^\n]*)*(\r?\n|$)/mi, "").replace(/\r?\n$/, "");
5282
+ const rawToSend = bccHdrEnd === -1
5283
+ ? stripBcc(raw)
5284
+ : stripBcc(raw.slice(0, bccHdrEnd)) + raw.slice(bccHdrEnd);
5260
5285
  this.saveSendingCopy(accountId, rawToSend, "sent");
5261
5286
  const smtp = new SmtpClient({
5262
5287
  host: smtpHost,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx-imap",
3
- "version": "0.1.121",
3
+ "version": "0.1.124",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -9,9 +9,9 @@
9
9
  },
10
10
  "license": "ISC",
11
11
  "dependencies": {
12
- "@bobfrankston/mailx-types": "^0.1.25",
13
- "@bobfrankston/mailx-settings": "^0.1.35",
14
- "@bobfrankston/mailx-store": "^0.1.63",
12
+ "@bobfrankston/mailx-types": "^0.1.28",
13
+ "@bobfrankston/mailx-settings": "^0.1.38",
14
+ "@bobfrankston/mailx-store": "^0.1.65",
15
15
  "@bobfrankston/iflow-direct": "^0.1.59",
16
16
  "@bobfrankston/tcp-transport": "^0.1.8",
17
17
  "@bobfrankston/smtp-direct": "^0.1.9",
@@ -37,9 +37,9 @@
37
37
  },
38
38
  ".transformedSnapshot": {
39
39
  "dependencies": {
40
- "@bobfrankston/mailx-types": "^0.1.25",
41
- "@bobfrankston/mailx-settings": "^0.1.35",
42
- "@bobfrankston/mailx-store": "^0.1.63",
40
+ "@bobfrankston/mailx-types": "^0.1.28",
41
+ "@bobfrankston/mailx-settings": "^0.1.38",
42
+ "@bobfrankston/mailx-store": "^0.1.65",
43
43
  "@bobfrankston/iflow-direct": "^0.1.59",
44
44
  "@bobfrankston/tcp-transport": "^0.1.8",
45
45
  "@bobfrankston/smtp-direct": "^0.1.9",