odoo/odoo#187153

Created by fw-bot
Merged at 0783d50e146f8aae6d3fa9b9b9db155c124fa012

Statuses:

label
odoo-dev:18.0-16.0-fix-extract-email-tde-Kjbc-fw
head
fc3e1455ab759d1aaa820276065a63a3f0bbd011
merged
1 year ago by Marketing, Thibault Delavallee (tde)
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
saas-19.1
saas-19.2
master #187215

[FW][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

Forward-Port-Of: #186967
Forward-Port-Of: #185793