diff --git a/mail_server/mail_server/doctype/outgoing_mail_log/outgoing_mail_log.py b/mail_server/mail_server/doctype/outgoing_mail_log/outgoing_mail_log.py index 65fcdde..6a21f8b 100644 --- a/mail_server/mail_server/doctype/outgoing_mail_log/outgoing_mail_log.py +++ b/mail_server/mail_server/doctype/outgoing_mail_log/outgoing_mail_log.py @@ -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() @@ -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.")) @@ -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, } diff --git a/mail_server/utils/email_parser.py b/mail_server/utils/email_parser.py index af9f447..edacd1f 100644 --- a/mail_server/utils/email_parser.py +++ b/mail_server/utils/email_parser.py @@ -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."""