Merge pull request #43 from simple-login/notify-user-reply

Notify user reply
This commit is contained in:
Son Nguyen Kim 2020-01-23 10:24:38 +01:00 committed by GitHub
commit c279033330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 0 deletions

View File

@ -143,6 +143,31 @@ def send_cannot_create_domain_alias(user, alias, domain):
)
def send_reply_alias_must_use_personal_email(user, alias, sender):
"""
The reply_email can be used only by user personal email.
Notify user if it's used by someone else
"""
send_email(
user.email,
f"Reply from your alias {alias} only works with your personal email",
_render(
"reply-must-use-personal-email.txt",
name=user.name,
alias=alias,
sender=sender,
user_email=user.email,
),
_render(
"reply-must-use-personal-email.html",
name=user.name,
alias=alias,
sender=sender,
user_email=user.email,
),
)
def send_email(to_email, subject, plaintext, html):
if NOT_SEND_EMAIL:
LOG.d(

View File

@ -50,6 +50,7 @@ from app.email_utils import (
send_cannot_create_directory_alias,
send_cannot_create_domain_alias,
email_belongs_to_alias_domains,
send_reply_alias_must_use_personal_email,
)
from app.extensions import db
from app.log import LOG
@ -302,6 +303,12 @@ class MailHandler:
reply_email,
)
send_reply_alias_must_use_personal_email(
forward_email.gen_email.user,
forward_email.gen_email.email,
envelope.mail_from,
)
send_email(
envelope.mail_from,
f"Your email ({envelope.mail_from}) is not allowed to send email to {reply_email}",

View File

@ -0,0 +1,8 @@
Hi {{name}} <br><br>
We have recorded an attempt to send an email from your alias <b>{{ alias }}</b> using <b>{{ sender }}</b>. <br><br>
Please note that sending from alias only works from your personal email ({{user_email}}): no one else could send emails on behalf of your alias. <br><br>
Best, <br>
SimpleLogin team.

View File

@ -0,0 +1,8 @@
Hi {{name}}
We have recorded an attempt to send an email from your alias {{ alias }} using {{ sender }}.
Please note that sending from alias only works from your personal email ({{user_email}}): no one else could send emails on behalf of your alias.
Best,
SimpleLogin team.