mirror of
https://github.com/simple-login/app.git
synced 2024-09-20 17:01:29 +02:00
small refactor: add should_add_dkim_signature
This commit is contained in:
parent
e79522b638
commit
1fcf166c00
@ -37,7 +37,7 @@ from app.config import (
|
|||||||
from app.dns_utils import get_mx_domains
|
from app.dns_utils import get_mx_domains
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
from app.log import LOG
|
from app.log import LOG
|
||||||
from app.models import Mailbox, User, SentAlert, CustomDomain
|
from app.models import Mailbox, User, SentAlert, CustomDomain, PublicDomain
|
||||||
|
|
||||||
|
|
||||||
def render(template_name, **kwargs) -> str:
|
def render(template_name, **kwargs) -> str:
|
||||||
@ -627,3 +627,14 @@ def to_bytes(msg: Message):
|
|||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
LOG.warning("as_bytes fails with SMTP policy, try SMTPUTF8 policy")
|
LOG.warning("as_bytes fails with SMTP policy, try SMTPUTF8 policy")
|
||||||
return msg.as_bytes(policy=email.policy.SMTPUTF8)
|
return msg.as_bytes(policy=email.policy.SMTPUTF8)
|
||||||
|
|
||||||
|
|
||||||
|
def should_add_dkim_signature(domain: str) -> bool:
|
||||||
|
if PublicDomain.get_by(domain=domain):
|
||||||
|
return True
|
||||||
|
|
||||||
|
custom_domain: CustomDomain = CustomDomain.get_by(domain=domain)
|
||||||
|
if custom_domain.dkim_verified:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
@ -98,6 +98,7 @@ from app.email_utils import (
|
|||||||
get_header_from_bounce,
|
get_header_from_bounce,
|
||||||
send_email_at_most_times,
|
send_email_at_most_times,
|
||||||
is_valid_alias_address_domain,
|
is_valid_alias_address_domain,
|
||||||
|
should_add_dkim_signature,
|
||||||
)
|
)
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
from app.greylisting import greylisting_needed
|
from app.greylisting import greylisting_needed
|
||||||
@ -874,13 +875,8 @@ def handle_reply(envelope, msg: Message, rcpt_to: str) -> (bool, str):
|
|||||||
else:
|
else:
|
||||||
msg = replace_str_in_msg(msg, reply_email, contact.website_email)
|
msg = replace_str_in_msg(msg, reply_email, contact.website_email)
|
||||||
|
|
||||||
if alias_domain in ALIAS_DOMAINS or alias_domain in PREMIUM_ALIAS_DOMAINS:
|
if should_add_dkim_signature(alias_domain):
|
||||||
add_dkim_signature(msg, alias_domain)
|
add_dkim_signature(msg, alias_domain)
|
||||||
# add DKIM-Signature for custom-domain alias
|
|
||||||
else:
|
|
||||||
custom_domain: CustomDomain = CustomDomain.get_by(domain=alias_domain)
|
|
||||||
if custom_domain.dkim_verified:
|
|
||||||
add_dkim_signature(msg, alias_domain)
|
|
||||||
|
|
||||||
# create PGP email if needed
|
# create PGP email if needed
|
||||||
if contact.pgp_finger_print and user.is_premium():
|
if contact.pgp_finger_print and user.is_premium():
|
||||||
|
Loading…
Reference in New Issue
Block a user