odoo/odoo#185793

Created by Marketing, Thibault Delavallee (tde)
Merged at 41b9e562b95f7c8f80e44de61ae1fbf899535f7d

Statuses:

label
odoo-dev:16.0-fix-extract-email-tde
head
b1702477d0e2e4c5407edab198ecb867b9ddd221
merged
1 year ago by SM Learn, Julien Castiaux (juc)
odoo/odoo
16.0 #185793
17.0 #186798
saas-17.2 #186951
saas-17.4 #186967
18.0 #187153
saas-18.2
saas-18.3
saas-18.4
19.0
master #187215

[FIX] base, mail: avoid duplicate/wrong email extract when sending emails

Use cases: send an email to
"Bike@Home" <info@bike.com> (name containing @)
"robert@exampl.com" <robert@example.com> (result of partner name_create)

When there is an email in the name field, emails are sent twice and
thus may be counted twice in various tooling, introduce unwanted or
extra recipients, ... This happens notably due to 795091c69d2bc40e3bd2b5ae29451ea3af07d908
combined to #74474 which improved support of multiemails and
formatted emails in various email input.

This notably leads to better formatted email computation on partner
that generates emails like '"email@example.com" <email@example.com>'
when email is used both as name and email. When sending emails to this
partner only a single email should be sent and counted.

A fix is been done to remove duplicates in that tool, making the returned
list unique. In this PR we allow to receive a pre-validated
list of emails that restricts emails found by 'extract_rfc2822'.
When going through classic flows, we already computed emails using
'email_split' and its subtools, hence we just need the encoding
check of 'extract_rfc2822'. Additional emails found by that tool
are ignored as we consider those are fake emails.

This PR contains tests and fixes related to that issue as well as multi
and formatted emails management.

task-3704658