mirror of
https://github.com/simple-login/app.git
synced 2025-02-25 16:23:16 +08:00
set a custom Message-ID header
This commit is contained in:
parent
637bc569eb
commit
d410b34b50
1 changed files with 8 additions and 1 deletions
|
@ -39,7 +39,7 @@ from email import encoders
|
||||||
from email.message import Message
|
from email.message import Message
|
||||||
from email.mime.application import MIMEApplication
|
from email.mime.application import MIMEApplication
|
||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
from email.utils import parseaddr, formataddr
|
from email.utils import parseaddr, formataddr, make_msgid
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from smtplib import SMTP
|
from smtplib import SMTP
|
||||||
from typing import List, Tuple
|
from typing import List, Tuple
|
||||||
|
@ -111,6 +111,7 @@ from server import create_app, create_light_app
|
||||||
_IP_HEADER = "X-SimpleLogin-Client-IP"
|
_IP_HEADER = "X-SimpleLogin-Client-IP"
|
||||||
_MAILBOX_ID_HEADER = "X-SimpleLogin-Mailbox-ID"
|
_MAILBOX_ID_HEADER = "X-SimpleLogin-Mailbox-ID"
|
||||||
_EMAIL_LOG_ID_HEADER = "X-SimpleLogin-EmailLog-ID"
|
_EMAIL_LOG_ID_HEADER = "X-SimpleLogin-EmailLog-ID"
|
||||||
|
_MESSAGE_ID = "Message-ID"
|
||||||
|
|
||||||
# fix the database connection leak issue
|
# fix the database connection leak issue
|
||||||
# use this method instead of create_app
|
# use this method instead of create_app
|
||||||
|
@ -497,6 +498,7 @@ async def forward_email_to_mailbox(
|
||||||
delete_header(msg, _IP_HEADER)
|
delete_header(msg, _IP_HEADER)
|
||||||
add_or_replace_header(msg, _MAILBOX_ID_HEADER, str(mailbox.id))
|
add_or_replace_header(msg, _MAILBOX_ID_HEADER, str(mailbox.id))
|
||||||
add_or_replace_header(msg, _EMAIL_LOG_ID_HEADER, str(email_log.id))
|
add_or_replace_header(msg, _EMAIL_LOG_ID_HEADER, str(email_log.id))
|
||||||
|
add_or_replace_header(msg, _MESSAGE_ID, make_msgid(str(email_log.id), EMAIL_DOMAIN))
|
||||||
|
|
||||||
# change the from header so the sender comes from @SL
|
# change the from header so the sender comes from @SL
|
||||||
# so it can pass DMARC check
|
# so it can pass DMARC check
|
||||||
|
@ -677,6 +679,11 @@ async def handle_reply(envelope, smtp: SMTP, msg: Message, rcpt_to: str) -> (boo
|
||||||
replace_header_when_reply(msg, alias, "To")
|
replace_header_when_reply(msg, alias, "To")
|
||||||
replace_header_when_reply(msg, alias, "Cc")
|
replace_header_when_reply(msg, alias, "Cc")
|
||||||
|
|
||||||
|
add_or_replace_header(
|
||||||
|
msg,
|
||||||
|
_MESSAGE_ID,
|
||||||
|
make_msgid(str(email_log.id), get_email_domain_part(alias.email)),
|
||||||
|
)
|
||||||
# Received-SPF is injected by postfix-policyd-spf-python can reveal user original email
|
# Received-SPF is injected by postfix-policyd-spf-python can reveal user original email
|
||||||
delete_header(msg, "Received-SPF")
|
delete_header(msg, "Received-SPF")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue