fix email thread: do not delete original message id
This commit is contained in:
parent
a7f82b2110
commit
9bb83fe3e2
|
@ -0,0 +1,5 @@
|
||||||
|
"""Email headers"""
|
||||||
|
MESSAGE_ID = "Message-ID"
|
||||||
|
IN_REPLY_TO = "In-Reply-To"
|
||||||
|
REFERENCES = "References"
|
||||||
|
DATE = "date"
|
|
@ -85,7 +85,7 @@ from app.config import (
|
||||||
ALERT_YAHOO_COMPLAINT,
|
ALERT_YAHOO_COMPLAINT,
|
||||||
TEMP_DIR,
|
TEMP_DIR,
|
||||||
)
|
)
|
||||||
from app.email import status
|
from app.email import status, headers
|
||||||
from app.email.rate_limit import rate_limited
|
from app.email.rate_limit import rate_limited
|
||||||
from app.email.spam import get_spam_score
|
from app.email.spam import get_spam_score
|
||||||
from app.email_utils import (
|
from app.email_utils import (
|
||||||
|
@ -157,6 +157,7 @@ _MIME_HEADERS = [
|
||||||
]
|
]
|
||||||
_MIME_HEADERS = [h.lower() for h in _MIME_HEADERS]
|
_MIME_HEADERS = [h.lower() for h in _MIME_HEADERS]
|
||||||
|
|
||||||
|
|
||||||
newrelic_app = None
|
newrelic_app = None
|
||||||
if NEWRELIC_CONFIG_PATH:
|
if NEWRELIC_CONFIG_PATH:
|
||||||
newrelic.agent.initialize(NEWRELIC_CONFIG_PATH)
|
newrelic.agent.initialize(NEWRELIC_CONFIG_PATH)
|
||||||
|
@ -751,9 +752,11 @@ def forward_email_to_mailbox(
|
||||||
"To",
|
"To",
|
||||||
"Cc",
|
"Cc",
|
||||||
"Subject",
|
"Subject",
|
||||||
|
# do not delete original message id
|
||||||
|
headers.MESSAGE_ID,
|
||||||
# References and In-Reply-To are used for keeping the email thread
|
# References and In-Reply-To are used for keeping the email thread
|
||||||
"References",
|
headers.REFERENCES,
|
||||||
"In-Reply-To",
|
headers.IN_REPLY_TO,
|
||||||
]
|
]
|
||||||
+ _MIME_HEADERS,
|
+ _MIME_HEADERS,
|
||||||
)
|
)
|
||||||
|
@ -790,10 +793,15 @@ def forward_email_to_mailbox(
|
||||||
msg[_ENVELOPE_FROM] = envelope.mail_from
|
msg[_ENVELOPE_FROM] = envelope.mail_from
|
||||||
# when an alias isn't in the To: header, there's no way for users to know what alias has received the email
|
# when an alias isn't in the To: header, there's no way for users to know what alias has received the email
|
||||||
msg[_ENVELOPE_TO] = alias.email
|
msg[_ENVELOPE_TO] = alias.email
|
||||||
message_id = make_msgid(str(email_log.id), EMAIL_DOMAIN)
|
|
||||||
LOG.d("message id %s", message_id)
|
if not msg[headers.MESSAGE_ID]:
|
||||||
msg["Message-ID"] = message_id
|
LOG.w("missing message id header, create one")
|
||||||
msg["Date"] = formatdate()
|
message_id = make_msgid(str(email_log.id), EMAIL_DOMAIN)
|
||||||
|
msg[headers.MESSAGE_ID] = message_id
|
||||||
|
|
||||||
|
if not msg[headers.DATE]:
|
||||||
|
LOG.w("missing date header, create one")
|
||||||
|
msg[headers.DATE] = formatdate()
|
||||||
|
|
||||||
# change the from header so the sender comes from a reverse-alias
|
# change the from header so the sender comes from a reverse-alias
|
||||||
# so it can pass DMARC check
|
# so it can pass DMARC check
|
||||||
|
@ -983,9 +991,11 @@ def handle_reply(envelope, msg: Message, rcpt_to: str) -> (bool, str):
|
||||||
"To",
|
"To",
|
||||||
"Cc",
|
"Cc",
|
||||||
"Subject",
|
"Subject",
|
||||||
|
# do not delete original message id
|
||||||
|
headers.MESSAGE_ID,
|
||||||
# References and In-Reply-To are used for keeping the email thread
|
# References and In-Reply-To are used for keeping the email thread
|
||||||
"References",
|
headers.REFERENCES,
|
||||||
"In-Reply-To",
|
headers.IN_REPLY_TO,
|
||||||
]
|
]
|
||||||
+ _MIME_HEADERS,
|
+ _MIME_HEADERS,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue