From 8769383724f35c58547539527d27a2c62d61e06e Mon Sep 17 00:00:00 2001 From: Sibren Vasse Date: Fri, 15 May 2020 16:34:07 +0200 Subject: [PATCH] Also enable spam check when pgp is enabled --- email_handler.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/email_handler.py b/email_handler.py index 19bc9c7b..afed1d4f 100644 --- a/email_handler.py +++ b/email_handler.py @@ -356,26 +356,20 @@ def handle_forward(envelope, smtp: SMTP, msg: Message, rcpt_to: str) -> (bool, s db.session.commit() return True, "250 Message accepted for delivery" - spam_check = True + is_spam, spam_status = get_spam_info(msg) + if is_spam: + LOG.warning("Email detected as spam. Alias: %s, from: %s", alias, contact) + email_log.is_spam = True + email_log.spam_status = spam_status + + handle_spam(contact, alias, msg, user, mailbox_email, email_log) + return False, "550 SL E1" # create PGP email if needed if mailbox.pgp_finger_print and user.is_premium(): LOG.d("Encrypt message using mailbox %s", mailbox) msg = prepare_pgp_message(msg, mailbox.pgp_finger_print) - # no need to spam check for encrypted message - spam_check = False - - if spam_check: - is_spam, spam_status = get_spam_info(msg) - if is_spam: - LOG.warning("Email detected as spam. Alias: %s, from: %s", alias, contact) - email_log.is_spam = True - email_log.spam_status = spam_status - - handle_spam(contact, alias, msg, user, mailbox_email, email_log) - return False, "550 SL E1" - # add custom header add_or_replace_header(msg, "X-SimpleLogin-Type", "Forward")