handle hotmail complaint during reply phase

This commit is contained in:
Son 2021-11-21 11:31:28 +01:00
parent bc936436ef
commit 77e38e63fe
3 changed files with 51 additions and 1 deletions

View File

@ -338,6 +338,8 @@ AlERT_WRONG_MX_RECORD_CUSTOM_DOMAIN = "custom_domain_mx_record_issue"
ALERT_DIRECTORY_DISABLED_ALIAS_CREATION = "alert_directory_disabled_alias_creation"
ALERT_HOTMAIL_COMPLAINT = "alert_hotmail_complaint"
ALERT_HOTMAIL_COMPLAINT_REPLY_PHASE = "alert_hotmail_complaint_reply_phase"
ALERT_HOTMAIL_COMPLAINT_TRANSACTIONAL = "alert_hotmail_complaint_transactional"
ALERT_YAHOO_COMPLAINT = "alert_yahoo_complaint"
# <<<<< END ALERT EMAIL >>>>

View File

@ -84,6 +84,8 @@ from app.config import (
ALERT_HOTMAIL_COMPLAINT,
ALERT_YAHOO_COMPLAINT,
TEMP_DIR,
ALERT_HOTMAIL_COMPLAINT_TRANSACTIONAL,
ALERT_HOTMAIL_COMPLAINT_REPLY_PHASE,
)
from app.db import Session
from app.email import status, headers
@ -1399,6 +1401,38 @@ def handle_hotmail_complaint(msg: Message) -> bool:
handle_hotmail_complain_for_transactional_email(user)
return True
try:
_, from_address = parse_full_address(get_header_unicode(from_header))
alias = Alias.get_by(email=from_address)
# the email is during a reply phase, from=alias and to=destination
if alias:
user = alias.user
LOG.i(
"Hotmail complaint during reply phase %s -> %s, %s",
alias,
to_header,
user,
)
send_email_with_rate_control(
user,
ALERT_HOTMAIL_COMPLAINT_REPLY_PHASE,
user.email,
f"Hotmail abuse report",
render(
"transactional/hotmail-complaint-reply-phase.txt.jinja2",
user=user,
alias=alias,
destination=to_header,
),
max_nb_alert=1,
nb_day=7,
)
return True
except ValueError:
LOG.w("Cannot parse %s", from_header)
alias = None
# try parsing the from header which might contain the reverse alias
@ -1456,7 +1490,7 @@ def handle_hotmail_complain_for_transactional_email(user):
"""Handle the case when a transactional email is set as Spam by user or by HotMail"""
send_email_with_rate_control(
user,
ALERT_HOTMAIL_COMPLAINT,
ALERT_HOTMAIL_COMPLAINT_TRANSACTIONAL,
user.email,
f"Hotmail abuse report",
render("transactional/hotmail-transactional-complaint.txt.jinja2", user=user),

View File

@ -0,0 +1,14 @@
Hi,
This is SimpleLogin team.
Hotmail has informed us about an email sent from your alias {{ alias.email }} to {{ destination }} that might have been considered as spam, either by the recipient or by their Hotmail spam filter.
Please note that sending non-solicited from a SimpleLogin alias infringes our terms and condition as it severely affects SimpleLogin email delivery.
If somehow the recipient's Hotmail considers a forwarded email as Spam, it helps us a lot if you can ask them to move the email out of their Spam folder.
Looking to hear back from you.
Best,
SimpleLogin Team.