From 6011ebccb40820ced838cd134bb532a34a6c88f7 Mon Sep 17 00:00:00 2001 From: s-aga-r Date: Thu, 14 Nov 2024 14:59:58 +0530 Subject: [PATCH] chore: preserve recipients order --- .../mail_client/doctype/outgoing_mail/outgoing_mail.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mail_client/mail_client/doctype/outgoing_mail/outgoing_mail.py b/mail_client/mail_client/doctype/outgoing_mail/outgoing_mail.py index 2d67e0d8..dc4629a2 100644 --- a/mail_client/mail_client/doctype/outgoing_mail/outgoing_mail.py +++ b/mail_client/mail_client/doctype/outgoing_mail/outgoing_mail.py @@ -666,7 +666,10 @@ def transfer_to_mail_server(self) -> None: message["X-Priority"] = "3" message = message.as_string() - recipients = list(set([rcpt.email for rcpt in self.recipients])) + # Remove duplicate recipients while preserving the order by using `dict.fromkeys()`. + # This avoids using a set, which could change the order of recipients. + recipients = list(dict.fromkeys([rcpt.email for rcpt in self.recipients])) + outbound_api = get_mail_server_outbound_api() token = outbound_api.send(self.name, recipients, message)