Notify user can reply cannot be sent

This commit is contained in:
Son NK 2020-06-20 16:19:01 +02:00
parent 45a8b360e4
commit 85bb30abb0
3 changed files with 74 additions and 9 deletions

View File

@ -636,17 +636,38 @@ def handle_reply(envelope, smtp: SMTP, msg: Message, rcpt_to: str) -> (bool, str
# so the client can retry later
return False, "421 SL E13"
smtp.sendmail(
alias.email,
contact.website_email,
msg.as_bytes(),
envelope.mail_options,
envelope.rcpt_options,
)
try:
smtp.sendmail(
alias.email,
contact.website_email,
msg.as_bytes(),
envelope.mail_options,
envelope.rcpt_options,
)
except Exception:
LOG.error("Cannot send email from %s to %s", alias, contact)
send_email(
mailbox.email,
f"Email cannot be sent to {contact.email} from {alias.email}",
render(
"transactional/reply-error.txt",
user=user,
alias=alias,
contact=contact,
contact_domain=get_email_domain_part(contact.email),
),
render(
"transactional/reply-error.html",
user=user,
alias=alias,
contact=contact,
contact_domain=get_email_domain_part(contact.email),
),
)
else:
EmailLog.create(contact_id=contact.id, is_reply=True, user_id=contact.user_id)
EmailLog.create(contact_id=contact.id, is_reply=True, user_id=contact.user_id)
db.session.commit()
return True, "250 Message accepted for delivery"

View File

@ -0,0 +1,30 @@
{% extends "base.html" %}
{% block content %}
{{ render_text("Hi " + (user.name or "")) }}
{% call text() %}
Your email cannot be sent to <b>{{ contact.email }}</b> from your alias <b>{{ alias.email }}</b>.
{% endcall %}
{% call text() %}
Can you please verify <b>{{ contact.email }}</b> is a valid address?
{% endcall %}
{% call text() %}
Usually this is because the DNS record of <b>{{ contact_domain }}</b> does not exist.
{% endcall %}
{% call text() %}
You can check its DNS record on any DNS checker websites, for example https://mxtoolbox.com/SuperTool.aspx
{% endcall %}
{% call text() %}
Please let us know if you have any question. <br>
Best, <br>
SimpleLogin team.
{% endcall %}
{% endblock %}

View File

@ -0,0 +1,14 @@
Hi {{user.name or ""}}
Your email cannot be sent to {{contact.email}} from your alias {{alias.email}}.
Can you please verify {{contact.email}} is a valid address?
Usually this is because the DNS record of {{contact_domain}} does not exist.
You can check its DNS record on any DNS checker websites, for example https://mxtoolbox.com/SuperTool.aspx
Please let us know if you have any question.
Best,
SimpleLogin team.