fix and refactor

This commit is contained in:
Son 2022-03-16 10:24:59 +01:00
parent cd693eda69
commit fa2f83dbf4
3 changed files with 4 additions and 5 deletions

View file

@ -30,6 +30,7 @@ SL_DIRECTION = "X-SimpleLogin-Type"
SL_EMAIL_LOG_ID = "X-SimpleLogin-EmailLog-ID"
SL_ENVELOPE_FROM = "X-SimpleLogin-Envelope-From"
SL_ENVELOPE_TO = "X-SimpleLogin-Envelope-To"
SL_CLIENT_IP = "X-SimpleLogin-Client-IP"
# to let Rspamd know that the message should be signed
SL_WANT_SIGNING = "X-SimpleLogin-Want-Signing"

View file

@ -19,6 +19,7 @@ E210 = "250 SL E210 Yahoo complaint handled"
E211 = "250 SL E211 Bounce Forward phase handled"
E212 = "250 SL E212 Bounce Reply phase handled"
E213 = "250 SL E213 Unknown email ignored"
E214 = "250 SL E214 Unauthorized for using reverse alias"
# endregion

View file

@ -1216,9 +1216,6 @@ def parse_id_from_bounce(email_address: str) -> int:
return int(email_address[email_address.find("+") : email_address.rfind("+")])
_IP_HEADER = "X-SimpleLogin-Client-IP"
def spf_pass(
envelope,
mailbox: Mailbox,
@ -1227,7 +1224,7 @@ def spf_pass(
contact_email: str,
msg: Message,
) -> bool:
ip = msg[_IP_HEADER]
ip = msg[headers.SL_CLIENT_IP]
if ip:
LOG.d("Enforce SPF on %s %s", ip, envelope.mail_from)
try:
@ -1273,7 +1270,7 @@ def spf_pass(
else:
LOG.w(
"Could not find %s header %s -> %s",
_IP_HEADER,
headers.SL_CLIENT_IP,
mailbox.email,
contact_email,
)