From e99a8b55e0cfea1f611936919c75e50c33a0aa79 Mon Sep 17 00:00:00 2001 From: ClaraCrazy Date: Tue, 3 Dec 2024 07:54:27 +0100 Subject: [PATCH] Avoid unpredictable behaviour on weird `undisclosed recipients:;` signal IMAP does not return the bcc field cleanly, in fact, node-imap and by extension imap-simple wont return a valid bcc (or cc for that matter) at all. Generally, you can only view those with the "envelope" attribute of a mail, but those are empty. Only clean option would be to somehow accesss and work with the rfc822 spec of `Original-Recipient`. --- application/imap-service.js | 1 + domain/mail-repository.js | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/application/imap-service.js b/application/imap-service.js index 99a2f73..9c24806 100644 --- a/application/imap-service.js +++ b/application/imap-service.js @@ -347,6 +347,7 @@ class ImapService extends EventEmitter { async _getMailHeaders(uids) { const fetchOptions = { + envelope: true, bodies: ['HEADER.FIELDS (FROM TO SUBJECT DATE)'], struct: false } diff --git a/domain/mail-repository.js b/domain/mail-repository.js index d414ba5..2d51ef7 100644 --- a/domain/mail-repository.js +++ b/domain/mail-repository.js @@ -27,7 +27,9 @@ class MailRepository { } add(to, mailSummary) { - this.mailSummaries.set(to.toLowerCase(), mailSummary) + if (to !== 'undefined') { + this.mailSummaries.set(to.toLowerCase(), mailSummary) + } } removeUid(uid, address) {