Skip to content

Commit

Permalink
chore: add X-FM-OML header
Browse files Browse the repository at this point in the history
  • Loading branch information
s-aga-r committed Oct 26, 2024
1 parent 5c36930 commit 94c282e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def validate_message(self) -> None:
from mail_server.utils.email_parser import EmailParser

parser = EmailParser(self.message)
parser.update_header("X-FM-OML", self.name)
self.priority = parser.get_header("X-Priority")
self.created_at = parser.get_date()
self.message_id = parser.get_message_id()
Expand All @@ -56,6 +57,7 @@ def validate_message(self) -> None:
self.message_size = parser.get_size()
self.is_newsletter = cint(parser.get_header("X-Newsletter"))
self.received_after = time_diff_in_seconds(self.received_at, self.created_at)
self.message = parser.get_message()

if not parser.get_header("DKIM-Signature"):
frappe.throw(_("Message does not contain DKIM Signature."))
Expand Down Expand Up @@ -238,7 +240,7 @@ def push_to_queue(self) -> None:

recipients = [r.email for r in self.recipients]
data = {
"outgoing_mail": self.outgoing_mail,
"outgoing_mail_log": self.name,
"recipients": recipients,
"message": self.message,
}
Expand Down
5 changes: 5 additions & 0 deletions mail_server/utils/email_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ def get_authentication_results(self) -> dict[str, int | str]:

return result

def get_message(self) -> str:
"""Returns the email message as a string."""

return self.message.as_string()


def remove_whitespace_characters(text: str) -> str:
"""Removes whitespace characters from the text."""
Expand Down

0 comments on commit 94c282e

Please sign in to comment.