Merge pull request #200 from SibrenVasse/dkim_fix

Fix reverse alias replacement
This commit is contained in:
Son Nguyen Kim 2020-05-21 20:08:38 +02:00 committed by GitHub
commit 57e3e29e70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 8 deletions

View File

@ -555,6 +555,16 @@ def handle_reply(envelope, smtp: SMTP, msg: Message, rcpt_to: str) -> (bool, str
envelope.rcpt_options,
)
# replace the "ra+string@simplelogin.co" by the alias in the email body
# as this is usually included in when replying
if user.replace_reverse_alias:
payload = (
msg.get_payload()
.encode()
.replace(reply_email.encode(), contact.website_email.encode())
)
msg.set_payload(payload)
if alias_domain in ALIAS_DOMAINS:
add_dkim_signature(msg, alias_domain)
# add DKIM-Signature for custom-domain alias
@ -563,17 +573,10 @@ def handle_reply(envelope, smtp: SMTP, msg: Message, rcpt_to: str) -> (bool, str
if custom_domain.dkim_verified:
add_dkim_signature(msg, alias_domain)
msg_raw = msg.as_string().encode()
# replace the "ra+string@simplelogin.co" by the alias in the email body
# as this is usually included in when replying
if user.replace_reverse_alias:
msg_raw = msg_raw.replace(reply_email.encode(), alias.email.encode())
smtp.sendmail(
alias.email,
contact.website_email,
msg_raw,
msg.as_bytes(),
envelope.mail_options,
envelope.rcpt_options,
)