Preserve original from header in X-SimpleLogin-Original-From (#1784)

* Preserve original from in the headers

* Update the settings page

---------

Co-authored-by: Adrià Casajús <adria.casajus@proton.ch>
This commit is contained in:
Adrià Casajús 2023-06-23 12:43:06 +02:00 committed by GitHub
parent 8512093bfc
commit d3aae31d45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 2 deletions

View File

@ -33,6 +33,7 @@ DKIM_HEADERS = [
SL_DIRECTION = "X-SimpleLogin-Type" SL_DIRECTION = "X-SimpleLogin-Type"
SL_EMAIL_LOG_ID = "X-SimpleLogin-EmailLog-ID" SL_EMAIL_LOG_ID = "X-SimpleLogin-EmailLog-ID"
SL_ENVELOPE_FROM = "X-SimpleLogin-Envelope-From" SL_ENVELOPE_FROM = "X-SimpleLogin-Envelope-From"
SL_ORIGINAL_FROM = "X-SimpleLogin-Original-From"
SL_ENVELOPE_TO = "X-SimpleLogin-Envelope-To" SL_ENVELOPE_TO = "X-SimpleLogin-Envelope-To"
SL_CLIENT_IP = "X-SimpleLogin-Client-IP" SL_CLIENT_IP = "X-SimpleLogin-Client-IP"

View File

@ -897,6 +897,7 @@ def forward_email_to_mailbox(
msg[headers.SL_EMAIL_LOG_ID] = str(email_log.id) msg[headers.SL_EMAIL_LOG_ID] = str(email_log.id)
if user.include_header_email_header: if user.include_header_email_header:
msg[headers.SL_ENVELOPE_FROM] = envelope.mail_from msg[headers.SL_ENVELOPE_FROM] = envelope.mail_from
msg[headers.SL_ORIGINAL_FROM] = contact.website_email
# when an alias isn't in the To: header, there's no way for users to know what alias has received the email # when an alias isn't in the To: header, there's no way for users to know what alias has received the email
msg[headers.SL_ENVELOPE_TO] = alias.email msg[headers.SL_ENVELOPE_TO] = alias.email

View File

@ -684,7 +684,8 @@
SimpleLogin forwards emails to your mailbox from the <b>reverse-alias</b> and not from the <b>original</b> SimpleLogin forwards emails to your mailbox from the <b>reverse-alias</b> and not from the <b>original</b>
sender address. sender address.
<br /> <br />
If this option is enabled, the original sender addresses is stored in the email header <b>X-SimpleLogin-Envelope-From</b>. If this option is enabled, the original sender addresses is stored in the email header <b>X-SimpleLogin-Envelope-From</b>
and the original From header is stored in <b>X-SimpleLogin-Original-From<b>.
You can choose to display this header in your email client. You can choose to display this header in your email client.
<br /> <br />
As email headers aren't encrypted, your mailbox service can know the sender address via this header. As email headers aren't encrypted, your mailbox service can know the sender address via this header.

View File

@ -24,6 +24,7 @@ References:
<af07e94a66ece6564ae30a2aaac7a34c@frontapp.com> <af07e94a66ece6564ae30a2aaac7a34c@frontapp.com>
From: {{ sender_address }} From: {{ sender_address }}
To: {{ recipient_address }} To: {{ recipient_address }}
CC: {{ cc_address }}
Subject: Something Subject: Something
Message-ID: <af07e94a66ece6564ae30a2aaac7a34c@frontapp.com> Message-ID: <af07e94a66ece6564ae30a2aaac7a34c@frontapp.com>
X-Mailer: Front (1.0; +https://frontapp.com; X-Mailer: Front (1.0; +https://frontapp.com;

View File

@ -17,7 +17,11 @@ def test_original_headers_from_preserved():
original_sender_address = random_email() original_sender_address = random_email()
msg = load_eml_file( msg = load_eml_file(
"replacement_on_forward_phase.eml", "replacement_on_forward_phase.eml",
{"sender_address": original_sender_address, "recipient_address": alias.email}, {
"sender_address": original_sender_address,
"recipient_address": alias.email,
"cc_address": random_email(),
},
) )
envelope = Envelope() envelope = Envelope()
envelope.mail_from = f"env.{original_sender_address}" envelope.mail_from = f"env.{original_sender_address}"
@ -28,6 +32,7 @@ def test_original_headers_from_preserved():
assert len(send_requests) == 1 assert len(send_requests) == 1
request = send_requests[0] request = send_requests[0]
assert request.msg[headers.SL_ENVELOPE_FROM] == envelope.mail_from assert request.msg[headers.SL_ENVELOPE_FROM] == envelope.mail_from
assert request.msg[headers.SL_ORIGINAL_FROM] == original_sender_address
assert ( assert (
request.msg[headers.AUTHENTICATION_RESULTS] request.msg[headers.AUTHENTICATION_RESULTS]
== msg[headers.AUTHENTICATION_RESULTS] == msg[headers.AUTHENTICATION_RESULTS]