From 6a68141d8de25db8d753a2249bf8beac6de27b1e Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Sat, 7 Nov 2020 13:00:45 +0100 Subject: [PATCH] Use mailbox generic subject for forwarded emails --- email_handler.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/email_handler.py b/email_handler.py index aa6b4f40..4ac21f41 100644 --- a/email_handler.py +++ b/email_handler.py @@ -99,6 +99,7 @@ from app.email_utils import ( send_email_at_most_times, is_valid_alias_address_domain, should_add_dkim_signature, + add_header, ) from app.extensions import db from app.greylisting import greylisting_needed @@ -397,7 +398,7 @@ def should_append_alias(msg: Message, address: str): def prepare_pgp_message( orig_msg: Message, pgp_fingerprint: str, public_key: str, can_sign: bool = False -): +) -> Message: msg = MIMEMultipart("encrypted", protocol="application/pgp-encrypted") # clone orig message to avoid modifying it @@ -687,6 +688,15 @@ def forward_email_to_mailbox( # create PGP email if needed if mailbox.pgp_finger_print and user.is_premium() and not alias.disable_pgp: LOG.d("Encrypt message using mailbox %s", mailbox) + if mailbox.generic_subject: + LOG.d("Use a generic subject for %s", mailbox) + add_or_replace_header(msg, "Subject", mailbox.generic_subject) + msg = add_header( + msg, + f"""Forwarded by SimpleLogin to {alias.email} with "{msg["Subject"]}" as subject""", + f"""Forwarded by SimpleLogin to {alias.email} with {msg["Subject"]} as subject""", + ) + try: msg = prepare_pgp_message( msg, mailbox.pgp_finger_print, mailbox.pgp_public_key, can_sign=True