Merge pull request #107 from simple-login/fix-sender

Fix sender
This commit is contained in:
Son Nguyen Kim 2020-03-13 12:01:11 +01:00 committed by GitHub
commit f86506e697
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 9 deletions

View file

@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
Support PGP Support PGP
Take into account Sender header
## [1.1.0] - 2020-03-13 ## [1.1.0] - 2020-03-13
Support multiple Mailboxes Support multiple Mailboxes

View file

@ -54,9 +54,7 @@ def mailbox_detail_route(mailbox_id):
): ):
flash(f"Email {new_email} already used", "error") flash(f"Email {new_email} already used", "error")
elif not can_be_used_as_personal_email(new_email): elif not can_be_used_as_personal_email(new_email):
flash( flash("You cannot use this email address as your mailbox", "error")
"You cannot use this email address as your mailbox", "error",
)
else: else:
mailbox.new_email = new_email mailbox.new_email = new_email
db.session.commit() db.session.commit()

View file

@ -313,8 +313,9 @@ def handle_forward(envelope, smtp: SMTP, msg: Message, rcpt_to: str) -> str:
# add custom header # add custom header
add_or_replace_header(msg, "X-SimpleLogin-Type", "Forward") add_or_replace_header(msg, "X-SimpleLogin-Type", "Forward")
# remove reply-to header if present # remove reply-to & sender header if present
delete_header(msg, "Reply-To") delete_header(msg, "Reply-To")
delete_header(msg, "Sender")
# change the from header so the sender comes from @SL # change the from header so the sender comes from @SL
# so it can pass DMARC check # so it can pass DMARC check
@ -405,9 +406,7 @@ def handle_reply(envelope, smtp: SMTP, msg: Message, rcpt_to: str) -> str:
# in this case Postfix will try to send a bounce report to original sender, which is # in this case Postfix will try to send a bounce report to original sender, which is
# the "reply email" # the "reply email"
if envelope.mail_from == "<>": if envelope.mail_from == "<>":
LOG.error( LOG.error("Bounce when sending to alias %s, user %s", alias, gen_email.user)
"Bounce when sending to alias %s, user %s", alias, gen_email.user,
)
handle_bounce( handle_bounce(
alias, envelope, forward_email, gen_email, msg, smtp, user, mailbox_email alias, envelope, forward_email, gen_email, msg, smtp, user, mailbox_email
@ -467,6 +466,9 @@ def handle_reply(envelope, smtp: SMTP, msg: Message, rcpt_to: str) -> str:
# make sure to delete it # make sure to delete it
delete_header(msg, "Reply-To") delete_header(msg, "Reply-To")
# remove sender header if present as this could reveal user real email
delete_header(msg, "Sender")
add_or_replace_header(msg, "To", forward_email.website_email) add_or_replace_header(msg, "To", forward_email.website_email)
# add List-Unsubscribe header # add List-Unsubscribe header

View file

@ -50,7 +50,7 @@ def test_create_custom_alias_without_note(flask_client):
r = flask_client.post( r = flask_client.post(
url_for("api.new_custom_alias", hostname="www.test.com"), url_for("api.new_custom_alias", hostname="www.test.com"),
headers={"Authentication": api_key.code}, headers={"Authentication": api_key.code},
json={"alias_prefix": "prefix", "alias_suffix": f".{word}@{EMAIL_DOMAIN}",}, json={"alias_prefix": "prefix", "alias_suffix": f".{word}@{EMAIL_DOMAIN}"},
) )
assert r.status_code == 201 assert r.status_code == 201

View file

@ -52,7 +52,7 @@ def test_custom_mode(flask_client):
r = flask_client.post( r = flask_client.post(
url_for("api.new_random_alias", hostname="www.test.com", mode="uuid"), url_for("api.new_random_alias", hostname="www.test.com", mode="uuid"),
headers={"Authentication": api_key.code}, headers={"Authentication": api_key.code},
json={"note": "test note",}, json={"note": "test note"},
) )
assert r.status_code == 201 assert r.status_code == 201