Reply to noreply@... once per user
This commit is contained in:
parent
c947e7cbd5
commit
15ce7b00d8
|
@ -318,6 +318,8 @@ ALERT_NON_REVERSE_ALIAS_REPLY_PHASE = "non_reverse_alias_reply_phase"
|
|||
|
||||
ALERT_FROM_ADDRESS_IS_REVERSE_ALIAS = "from_address_is_reverse_alias"
|
||||
|
||||
ALERT_TO_NOREPLY = "to_noreply"
|
||||
|
||||
ALERT_SPF = "spf"
|
||||
|
||||
ALERT_INVALID_TOTP_LOGIN = "invalid_totp_login"
|
||||
|
|
|
@ -86,6 +86,7 @@ from app.config import (
|
|||
ALERT_HOTMAIL_COMPLAINT_REPLY_PHASE,
|
||||
OLD_UNSUBSCRIBER,
|
||||
ALERT_FROM_ADDRESS_IS_REVERSE_ALIAS,
|
||||
ALERT_TO_NOREPLY,
|
||||
)
|
||||
from app.db import Session
|
||||
from app.email import status, headers
|
||||
|
@ -2078,6 +2079,18 @@ def should_ignore(mail_from: str, rcpt_tos: List[str]) -> bool:
|
|||
return False
|
||||
|
||||
|
||||
def send_no_reply_response(mail_from: str, msg: Message):
|
||||
user = User.get_by(email=mail_from)
|
||||
if user:
|
||||
send_email_at_most_times(
|
||||
user,
|
||||
ALERT_TO_NOREPLY,
|
||||
user.email,
|
||||
"Auto: {}".format(msg[headers.SUBJECT] or "No subject"),
|
||||
render("transactional/noreply.text.jinja2"),
|
||||
)
|
||||
|
||||
|
||||
def handle(envelope: Envelope, msg: Message) -> str:
|
||||
"""Return SMTP status"""
|
||||
|
||||
|
@ -2300,8 +2313,9 @@ def handle(envelope: Envelope, msg: Message) -> str:
|
|||
nb_rcpt_tos = len(rcpt_tos)
|
||||
for rcpt_index, rcpt_to in enumerate(rcpt_tos):
|
||||
if rcpt_to == NOREPLY:
|
||||
LOG.e("email sent to noreply address from %s", mail_from)
|
||||
return status.E514
|
||||
LOG.i("email sent to {} address from {}".format(NOREPLY, mail_from))
|
||||
send_no_reply_response(mail_from, msg)
|
||||
return status.E200
|
||||
|
||||
# create a copy of msg for each recipient except the last one
|
||||
# as copy() is a slow function
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
Hi!
|
||||
|
||||
Thanks for getting in touch. This mailbox cannot receive any emails. If you need help, please go to https://app.simplelogin.io/dashboard/support to contact us.
|
||||
|
||||
Best!
|
||||
|
||||
SimpleLogin team
|
Loading…
Reference in New Issue