diff --git a/package-lock.json b/package-lock.json index 5610287..660820f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "better-sqlite3": "^12.11.1", "drizzle-orm": "^0.45.2", "framer-motion": "^12.4.7", + "html-to-text": "^10.0.0", "imapflow": "^1.5.0", "ldapjs": "^3.0.7", "lucide-react": "^0.545.0", diff --git a/package.json b/package.json index 4f16ab8..825abd4 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "better-sqlite3": "^12.11.1", "drizzle-orm": "^0.45.2", "framer-motion": "^12.4.7", + "html-to-text": "^10.0.0", "imapflow": "^1.5.0", "ldapjs": "^3.0.7", "lucide-react": "^0.545.0", diff --git a/src/lib/mail/imap.ts b/src/lib/mail/imap.ts index 5779e1a..988bf19 100644 --- a/src/lib/mail/imap.ts +++ b/src/lib/mail/imap.ts @@ -1,5 +1,6 @@ import { ImapFlow } from "imapflow"; import { simpleParser, type ParsedMail } from "mailparser"; +import { htmlToText } from "html-to-text"; import { getMailboxSettings, saveMailboxSettings, disableMailboxConfig, type MailboxSettings } from "@/lib/mail/config"; import { recordEmailInboundMessage } from "@/lib/tickets/service"; import { saveAttachment } from "@/lib/attachments/storage"; @@ -28,11 +29,16 @@ function createClient(settings: MailboxSettings): ImapFlow { }); } +// Prefer converting the HTML part ourselves rather than trusting parsed.text +// blindly — some senders (Outlook in particular) produce a text/plain +// alternative that isn't actually clean, while html-to-text reliably drops +//
/