warn users if SL is used with another forwarding service

This commit is contained in:
Son 2022-01-08 00:42:03 +01:00
parent ed4acebdb1
commit 862d0e7a11
3 changed files with 34 additions and 6 deletions

View File

@ -317,6 +317,8 @@ ALERT_SEND_EMAIL_CYCLE = "cycle"
ALERT_NON_REVERSE_ALIAS_REPLY_PHASE = "non_reverse_alias_reply_phase"
ALERT_FROM_ADDRESS_IS_REVERSE_ALIAS = "from_address_is_reverse_alias"
ALERT_SPF = "spf"
# when a mailbox is also an alias

View File

@ -86,6 +86,7 @@ from app.config import (
ALERT_HOTMAIL_COMPLAINT_REPLY_PHASE,
OLD_UNSUBSCRIBER,
ALERT_NON_REVERSE_ALIAS_REPLY_PHASE,
ALERT_FROM_ADDRESS_IS_REVERSE_ALIAS,
)
from app.db import Session
from app.email import status, headers
@ -133,7 +134,6 @@ from app.errors import (
VERPTransactional,
VERPForward,
VERPReply,
MailSentFromReverseAlias,
CannotCreateContactForReverseAlias,
)
from app.log import LOG, set_message_id
@ -2084,10 +2084,10 @@ def handle(envelope: Envelope, msg: Message) -> str:
)
# region mail_from or from_header is a reverse alias which should never happen
email_sent_from_reverse_alias = False
contact = Contact.get_by(reply_email=mail_from)
if contact:
raise MailSentFromReverseAlias(f"{contact} {contact.alias} {contact.user}")
email_sent_from_reverse_alias = True
from_header = get_header_unicode(msg[headers.FROM])
if from_header:
@ -2098,9 +2098,20 @@ def handle(envelope: Envelope, msg: Message) -> str:
else:
contact = Contact.get_by(reply_email=from_header_address)
if contact:
raise MailSentFromReverseAlias(
f"{contact} {contact.alias} {contact.user}"
)
email_sent_from_reverse_alias = True
if email_sent_from_reverse_alias:
LOG.w(f"email sent from reverse alias {contact} {contact.alias} {contact.user}")
user = contact.user
send_email_at_most_times(
user,
ALERT_FROM_ADDRESS_IS_REVERSE_ALIAS,
user.email,
"SimpleLogin shouldn't be used with another email forwarding system",
render(
"transactional/email-sent-from-reverse-alias.txt.jinja2",
),
)
# endregion

View File

@ -0,0 +1,15 @@
We have detected that SimpleLogin is probably used along with another forwarding email service.
Please note that the following use cases aren't supported by SimpleLogin:
- your mailbox is an email alias (i.e. not a "final" email address)
- your mailbox automatic forwarding enabled
- your alias receives automatic forwarding email from another mailbox
As different email forwarding systems are usually incompatible, using several forwarding services can cause issue
with email delivery.
Please let us know if you have any question.
Best,
SimpleLogin team.