use mailbox_email when notifying user attempt to send from his alias

This commit is contained in:
Son NK 2020-02-11 22:46:53 +07:00
parent d1241c6e18
commit b41a61165c
5 changed files with 22 additions and 32 deletions

View File

@ -167,31 +167,6 @@ 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(
"transactional/reply-must-use-personal-email.txt",
name=user.name,
alias=alias,
sender=sender,
user_email=user.email,
),
render(
"transactional/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): def send_email(to_email, subject, plaintext, html):
if NOT_SEND_EMAIL: if NOT_SEND_EMAIL:
LOG.d( LOG.d(

View File

@ -50,7 +50,7 @@ from app.email_utils import (
send_cannot_create_directory_alias, send_cannot_create_directory_alias,
send_cannot_create_domain_alias, send_cannot_create_domain_alias,
email_belongs_to_alias_domains, email_belongs_to_alias_domains,
send_reply_alias_must_use_personal_email, render,
) )
from app.extensions import db from app.extensions import db
from app.log import LOG from app.log import LOG
@ -328,10 +328,24 @@ class MailHandler:
reply_email, reply_email,
) )
send_reply_alias_must_use_personal_email( user = gen_email.user
forward_email.gen_email.user, send_email(
forward_email.gen_email.email, mailbox_email,
envelope.mail_from, f"Reply from your alias {alias} only works from your mailbox",
render(
"transactional/reply-must-use-personal-email.txt",
name=user.name,
alias=alias,
sender=envelope.mail_from,
mailbox_email=mailbox_email,
),
render(
"transactional/reply-must-use-personal-email.html",
name=user.name,
alias=alias,
sender=envelope.mail_from,
mailbox_email=mailbox_email,
),
) )
send_email( send_email(

View File

@ -130,6 +130,7 @@ def fake_data():
activated=True, activated=True,
is_admin=True, is_admin=True,
otp_secret="base32secret3232", otp_secret="base32secret3232",
can_use_multiple_mailbox=True,
) )
db.session.commit() db.session.commit()

View File

@ -2,7 +2,7 @@ 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> 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> Please note that sending from alias only works from {{mailbox_email}}: only you (i.e. no one else) can send emails on behalf of your alias. <br><br>
Best, <br> Best, <br>
SimpleLogin team. SimpleLogin team.

View File

@ -2,7 +2,7 @@ Hi {{name}}
We have recorded an attempt to send an email from your alias {{ alias }} using {{ sender }}. 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. Please note that sending from this alias only works from {{mailbox_email}}: only you (i.e. no one else) can send emails on behalf of your alias.
Best, Best,
SimpleLogin team. SimpleLogin team.