mirror of
https://github.com/simple-login/app.git
synced 2025-02-23 23:34:05 +08:00
refactor
This commit is contained in:
parent
d0dd64bf7b
commit
826e4455cf
2 changed files with 6 additions and 5 deletions
|
@ -63,7 +63,6 @@ from app.utils import (
|
|||
convert_to_alphanumeric,
|
||||
sanitize_email,
|
||||
)
|
||||
from email_handler import _IP_HEADER
|
||||
|
||||
|
||||
def render(template_name, **kwargs) -> str:
|
||||
|
@ -997,8 +996,10 @@ 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(
|
||||
ip: str,
|
||||
envelope,
|
||||
mailbox: Mailbox,
|
||||
user: User,
|
||||
|
@ -1006,6 +1007,7 @@ def spf_pass(
|
|||
contact_email: str,
|
||||
msg: Message,
|
||||
) -> bool:
|
||||
ip = msg[_IP_HEADER]
|
||||
if ip:
|
||||
LOG.d("Enforce SPF on %s %s", ip, envelope.mail_from)
|
||||
try:
|
||||
|
|
|
@ -125,7 +125,7 @@ from server import create_app, create_light_app
|
|||
# forward or reply
|
||||
_DIRECTION = "X-SimpleLogin-Type"
|
||||
|
||||
_IP_HEADER = "X-SimpleLogin-Client-IP"
|
||||
|
||||
_EMAIL_LOG_ID_HEADER = "X-SimpleLogin-EmailLog-ID"
|
||||
_ENVELOPE_FROM = "X-SimpleLogin-Envelope-From"
|
||||
|
||||
|
@ -804,8 +804,7 @@ def handle_reply(envelope, msg: Message, rcpt_to: str) -> (bool, str):
|
|||
return False, "550 SL E7"
|
||||
|
||||
if ENFORCE_SPF and mailbox.force_spf and not alias.disable_email_spoofing_check:
|
||||
ip = msg[_IP_HEADER]
|
||||
if not spf_pass(ip, envelope, mailbox, user, alias, contact.website_email, msg):
|
||||
if not spf_pass(envelope, mailbox, user, alias, contact.website_email, msg):
|
||||
# cannot use 4** here as sender will retry. 5** because that generates bounce report
|
||||
return True, "250 SL E11"
|
||||
|
||||
|
|
Loading…
Reference in a new issue