From a081298756794a2e4755243986386eeab7b45463 Mon Sep 17 00:00:00 2001 From: Son NK <> Date: Sun, 5 Apr 2020 11:59:24 +0200 Subject: [PATCH] use website_email instead of website_from in bounce-email --- email_handler.py | 10 ++++------ templates/emails/transactional/bounced-email.txt | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/email_handler.py b/email_handler.py index e97dc7da..2bfb30c3 100644 --- a/email_handler.py +++ b/email_handler.py @@ -445,7 +445,7 @@ def handle_reply(envelope, smtp: SMTP, msg: Message, rcpt_to: str) -> (bool, str LOG.warning( "Bounce when sending to alias %s from %s, user %s", alias, - contact.website_from, + contact.website_email, alias.user, ) @@ -597,18 +597,17 @@ def handle_bounce( LOG.d( "Inform user %s about bounced email sent by %s to alias %s", user, - contact.website_from, + contact.website_email, address, ) send_email( # use user mail here as only user is authenticated to see the refused email user.email, - f"Email from {contact.website_from} to {address} cannot be delivered to your inbox", + f"Email from {contact.website_email} to {address} cannot be delivered to your inbox", render( "transactional/bounced-email.txt", name=user.name, alias=alias, - website_from=contact.website_from, website_email=contact.website_email, disable_alias_link=disable_alias_link, refused_email_url=refused_email_url, @@ -618,7 +617,6 @@ def handle_bounce( "transactional/bounced-email.html", name=user.name, alias=alias, - website_from=contact.website_from, website_email=contact.website_email, disable_alias_link=disable_alias_link, refused_email_url=refused_email_url, @@ -632,7 +630,7 @@ def handle_bounce( LOG.d( "Bounce happens again with alias %s from %s. Disable alias now ", address, - contact.website_from, + contact.website_email, ) alias.enabled = False db.session.commit() diff --git a/templates/emails/transactional/bounced-email.txt b/templates/emails/transactional/bounced-email.txt index a4fb8cc1..fe4d9fd6 100644 --- a/templates/emails/transactional/bounced-email.txt +++ b/templates/emails/transactional/bounced-email.txt @@ -1,6 +1,6 @@ Hi {{name}} -An email sent to your alias {{alias.email}} from {{website_from}} was refused (or bounced) by your mailbox {{mailbox_email}}. +An email sent to your alias {{alias.email}} from {{website_email}} was refused (or bounced) by your mailbox {{mailbox_email}}. This is usually due to the email being considered as spam by your email provider. You can view this email here: