diff --git a/app/config.py b/app/config.py index 0c34fde6..16bdc1eb 100644 --- a/app/config.py +++ b/app/config.py @@ -157,6 +157,9 @@ DISABLE_ALIAS_SUFFIX = "DISABLE_ALIAS_SUFFIX" in os.environ # the email address that receives all unsubscription request UNSUBSCRIBER = os.environ.get("UNSUBSCRIBER") +# due to a typo, both UNSUBSCRIBER and OLD_UNSUBSCRIBER are supported +OLD_UNSUBSCRIBER = os.environ.get("OLD_UNSUBSCRIBER") + DKIM_SELECTOR = b"dkim" DKIM_PRIVATE_KEY = None diff --git a/email_handler.py b/email_handler.py index 93162b7b..7eedb1ae 100644 --- a/email_handler.py +++ b/email_handler.py @@ -86,6 +86,7 @@ from app.config import ( TEMP_DIR, ALERT_HOTMAIL_COMPLAINT_TRANSACTIONAL, ALERT_HOTMAIL_COMPLAINT_REPLY_PHASE, + OLD_UNSUBSCRIBER, ) from app.db import Session from app.email import status, headers @@ -2015,7 +2016,7 @@ def handle(envelope: Envelope) -> str: return status.E203 # unsubscribe request - if UNSUBSCRIBER and rcpt_tos == [UNSUBSCRIBER]: + if UNSUBSCRIBER and (rcpt_tos == [UNSUBSCRIBER] or rcpt_tos == [OLD_UNSUBSCRIBER]): LOG.d("Handle unsubscribe request from %s", mail_from) return handle_unsubscribe(envelope, msg)