Merge remote-tracking branch 'origin/master' into ac-dmarc-reply-phase

This commit is contained in:
Adrià Casajús 2022-04-08 11:34:12 +02:00
commit 8df6d98522
No known key found for this signature in database
GPG Key ID: F0033226A5AFC9B9
10 changed files with 40 additions and 12 deletions

View File

@ -6,6 +6,9 @@ import random
import time
import uuid
from copy import deepcopy
from aiosmtpd.smtp import Envelope
from email import policy, message_from_bytes, message_from_string
from email.header import decode_header, Header
from email.message import Message, EmailMessage
@ -1429,7 +1432,7 @@ def save_email_for_debugging(msg: Message, file_name_prefix=None) -> str:
if TEMP_DIR:
file_name = str(uuid.uuid4()) + ".eml"
if file_name_prefix:
file_name = file_name_prefix + file_name
file_name = "{}-{}".format(file_name_prefix, file_name)
with open(os.path.join(TEMP_DIR, file_name), "wb") as f:
f.write(msg.as_bytes())
@ -1438,3 +1441,22 @@ def save_email_for_debugging(msg: Message, file_name_prefix=None) -> str:
return file_name
return ""
def save_envelope_for_debugging(envelope: Envelope, file_name_prefix=None) -> str:
"""Save envelope for debugging to temporary location
Return the file path
"""
if TEMP_DIR:
file_name = str(uuid.uuid4()) + ".eml"
if file_name_prefix:
file_name = "{}-{}".format(file_name_prefix, file_name)
with open(os.path.join(TEMP_DIR, file_name), "wb") as f:
f.write(envelope.original_content)
LOG.d("envelope saved to %s", file_name)
return file_name
return ""

View File

@ -136,6 +136,7 @@ from app.email_utils import (
get_orig_message_from_yahoo_complaint,
get_mailbox_bounce_info,
save_email_for_debugging,
save_envelope_for_debugging,
)
from app.errors import (
NonReverseAliasInReplyPhase,
@ -2131,6 +2132,11 @@ def handle(envelope: Envelope, msg: Message) -> str:
envelope.mail_from = mail_from
envelope.rcpt_tos = rcpt_tos
# some emails don't have this header, set the default value (7bit) in this case
if headers.CONTENT_TRANSFER_ENCODING not in msg:
LOG.i("Set CONTENT_TRANSFER_ENCODING")
msg[headers.CONTENT_TRANSFER_ENCODING] = "7bit"
postfix_queue_id = get_queue_id(msg)
if postfix_queue_id:
set_message_id(postfix_queue_id)
@ -2467,7 +2473,7 @@ class MailHandler:
msg[headers.TO],
)
return status.E524
except (VERPReply, VERPForward) as e:
except (VERPReply, VERPForward, VERPTransactional) as e:
LOG.w(
"email handling fail with error:%s "
"mail_from:%s, rcpt_tos:%s, header_from:%s, header_to:%s",
@ -2487,8 +2493,8 @@ class MailHandler:
envelope.rcpt_tos,
msg[headers.FROM],
msg[headers.TO],
save_email_for_debugging(
msg, file_name_prefix=e.__class__.__name__
save_envelope_for_debugging(
envelope, file_name_prefix=e.__class__.__name__
), # todo: remove
)
return status.E404

View File

@ -11,5 +11,5 @@ Please note that sending non-solicited from a SimpleLogin alias infringes our te
If somehow the recipient's Hotmail considers a forwarded email as Spam, it helps us a lot if you can ask them to move the email out of their Spam folder.
Looking to hear back from you.
Don't hesitate to get in touch with us if you need more information.
{% endblock %}

View File

@ -28,7 +28,7 @@
{% endcall %}
{% call text() %}
Looking to hear back from you.
Don't hesitate to get in touch with us if you need more information.
{% endcall %}
{% call text() %}

View File

@ -16,5 +16,5 @@ If thats the case, please disable the alias instead if you don't want to rece
If somehow Hotmail considers a forwarded email as Spam, it will help us if you can move the email out of the Spam folder.
You can also set up a filter to avoid this from happening in the future using this guide at https://simplelogin.io/help/
Looking to hear back from you.
Don't hesitate to get in touch with us if you need more information.
{% endblock %}

View File

@ -29,7 +29,7 @@
{% endcall %}
{% call text() %}
Looking to hear back from you.
Don't hesitate to get in touch with us if you need more information.
{% endcall %}
{% call text() %}

View File

@ -19,5 +19,5 @@ If somehow Hotmail considers a forwarded email as Spam, it helps us if you can m
Please don't put our emails into the Spam folder. This can end up in your account being disabled on SimpleLogin.
Looking to hear back from you.
Don't hesitate to get in touch with us if you need more information.
{% endblock %}

View File

@ -24,7 +24,7 @@
{% endcall %}
{% call text() %}
Looking to hear back from you.
Don't hesitate to get in touch with us if you need more information.
{% endcall %}
{% call text() %}

View File

@ -14,5 +14,5 @@ If thats the case, please disable the alias instead if you don't want to rece
If SimpleLogin isnt useful for you, please know that you can simply delete your account on the Settings page.
Looking to hear back from you.
Don't hesitate to get in touch with us if you need more information.
{% endblock %}

View File

@ -29,7 +29,7 @@
{% endcall %}
{% call text() %}
Looking to hear back from you.
Don't hesitate to get in touch with us if you need more information.
{% endcall %}
{% call text() %}