From 7b96f199172592a80b4eec35a7c4f3e66ff4c428 Mon Sep 17 00:00:00 2001 From: 0xD0M1M0 <76812428+0xD0M1M0@users.noreply.github.com> Date: Thu, 20 Feb 2025 12:47:17 +0100 Subject: [PATCH] feat: (IMAP) Always BCC (#28961) --- frappe/email/doctype/email_account/email_account.json | 10 +++++++++- frappe/email/doctype/email_account/email_account.py | 1 + frappe/email/doctype/email_queue/email_queue.py | 5 ++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/frappe/email/doctype/email_account/email_account.json b/frappe/email/doctype/email_account/email_account.json index 1a44bec920..9811c11654 100644 --- a/frappe/email/doctype/email_account/email_account.json +++ b/frappe/email/doctype/email_account/email_account.json @@ -73,6 +73,7 @@ "smtp_port", "column_break_38", "no_smtp_authentication", + "always_bcc", "signature_section", "add_signature", "signature", @@ -699,12 +700,19 @@ "fieldname": "sent_folder_name", "fieldtype": "Data", "label": "Sent Folder Name" + }, + { + "description": "Use this, for example, if all sent emails should also be send to an archive.", + "fieldname": "always_bcc", + "fieldtype": "Data", + "label": "Always BCC Address", + "options": "Email" } ], "icon": "fa fa-inbox", "index_web_pages_for_search": 1, "links": [], - "modified": "2024-12-04 23:30:37.622353", + "modified": "2024-12-30 11:25:58.427173", "modified_by": "Administrator", "module": "Email", "name": "Email Account", diff --git a/frappe/email/doctype/email_account/email_account.py b/frappe/email/doctype/email_account/email_account.py index 88a2764eef..4a808feeb8 100755 --- a/frappe/email/doctype/email_account/email_account.py +++ b/frappe/email/doctype/email_account/email_account.py @@ -60,6 +60,7 @@ class EmailAccount(Document): from frappe.types import DF add_signature: DF.Check + always_bcc: DF.Data | None always_use_account_email_id_as_sender: DF.Check always_use_account_name_as_sender_name: DF.Check api_key: DF.Data | None diff --git a/frappe/email/doctype/email_queue/email_queue.py b/frappe/email/doctype/email_queue/email_queue.py index d446881962..7823491562 100644 --- a/frappe/email/doctype/email_queue/email_queue.py +++ b/frappe/email/doctype/email_queue/email_queue.py @@ -690,6 +690,9 @@ class QueueBuilder: return attachments def prepare_email_content(self): + email_account = self.get_outgoing_email_account() + if isinstance(self._bcc, list) and email_account.always_bcc is not None: + self._bcc.append(str(email_account.always_bcc)) mail = get_email( recipients=self.final_recipients(), sender=self.sender, @@ -700,7 +703,7 @@ class QueueBuilder: reply_to=self.reply_to, cc=self.final_cc(), bcc=self.bcc, - email_account=self.get_outgoing_email_account(), + email_account=email_account, expose_recipients=self.expose_recipients, inline_images=self.inline_images, header=self.header,