diff --git a/mail_composer_cc_bcc/models/mail_mail.py b/mail_composer_cc_bcc/models/mail_mail.py index e01ac8a0df..29e906780b 100644 --- a/mail_composer_cc_bcc/models/mail_mail.py +++ b/mail_composer_cc_bcc/models/mail_mail.py @@ -18,7 +18,13 @@ def format_emails(partners): emails = [ - tools.formataddr((p.name or "False", p.email or "False")) for p in partners + tools.formataddr( + ( + p.name or "False", + p.email and tools.mail._normalize_email(p.email) or "False", + ) + ) + for p in partners ] return ", ".join(emails) @@ -48,8 +54,8 @@ def _send( # noqa: max-complexity: 4 success_pids = [] failure_type = None # ===== Same with native Odoo ===== - # https://github.com/odoo/odoo/blob/1098b033b4e1811d6ff4b8c3b90aa6b9e697cb93 - # /addons/mail/models/mail_mail.py#L465 + # https://github.com/odoo/odoo/blob/2baa481e14ca705f4c6d3d4d900daf24442a4aa5 + # /addons/mail/models/mail_mail.py#L463 try: if mail.state != "outgoing": if mail.state != "exception" and mail.auto_delete: @@ -129,7 +135,7 @@ def _send( # noqa: max-complexity: 4 ) # protect against ill-formatted email_from when formataddr was used on an already formatted email # noqa: B950 - emails_from = tools.email_split_and_format(mail.email_from) + emails_from = tools.email_split_and_format_normalize(mail.email_from) email_from = emails_from[0] if emails_from else mail.email_from # build an RFC2822 email.message.Message object and send it without queuing diff --git a/mail_composer_cc_bcc/tests/test_mail_cc_bcc.py b/mail_composer_cc_bcc/tests/test_mail_cc_bcc.py index d8ebefcfe2..36bf2005cd 100644 --- a/mail_composer_cc_bcc/tests/test_mail_cc_bcc.py +++ b/mail_composer_cc_bcc/tests/test_mail_cc_bcc.py @@ -14,6 +14,7 @@ "d52cb36b88b33abc9556f7be6718d93f", "461467cd5b356072fc054468c75f6e26", "5d1ab352416f5074e131f35f20098d5b", + "46172c91183f2cb50b22a6b3b5e3869b", ]