fix DKIM fail on reply phase: the DKIM-signature should be added at the end of processing

This commit is contained in:
Son NK 2019-12-17 21:43:31 +02:00
parent 4799721667
commit 569fda47a9
1 changed files with 9 additions and 4 deletions

View File

@ -234,10 +234,10 @@ class MailHandler:
return "250 ignored"
# todo: add DKIM-Signature for custom domain
# add DKIM-Signature for non-custom-domain alias
if alias.endswith(EMAIL_DOMAIN):
add_dkim_signature(msg, EMAIL_DOMAIN)
# remove DKIM-Signature
if msg["DKIM-Signature"]:
LOG.d("Remove DKIM-Signature %s", msg["DKIM-Signature"])
del msg["DKIM-Signature"]
# email seems to come from alias
msg.replace_header("From", alias)
@ -258,6 +258,11 @@ class MailHandler:
envelope.rcpt_options,
)
# todo: add DKIM-Signature for custom domain
# add DKIM-Signature for non-custom-domain alias
if alias.endswith(EMAIL_DOMAIN):
add_dkim_signature(msg, EMAIL_DOMAIN)
msg_raw = msg.as_string().encode()
smtp.sendmail(
alias,