-
- Downloads
[FW][FIX] mail: ignore recipients linked to an external domain when checking aliases
This is a manual forward-port of 320ecc3f795bbbd70bfb43f1cc35e3f168a2feca and 383d2fd3880afed374c19b30dccc05edeaae77aa
done in 11 and 11.3.
/!\ It contains some additional content freom 11.0 (done in 11.3) /!\
It also includes direct write to catchall check improvement according to other
changes done in this commit. From now on only direct write to catchall bounce
and not writing to catchall and a valid alias anymore. More details below.
PURPOSE / RATIONALE
===================
Imagine this scenario A
1. In you DB there's an alias called "sales" and another one called
"purchases";
2. Your `mail.catchall.domain` is ``alice.example.com``;
3. Bob sends a new email with ``To: sales@bob.example.com,
purchases@alice.example.com``;
4. Odoo routes wrongly the incoming email to the "sales" alias although
it was just an additional external recipient;
It should have been ignored because it does not belong to your domain. Only
writing to ``sales@alice.example.com`` should be considered as a write to the
"sales" alias.
Another possible scenario B
1. In you DB there's an alias called "sales" and another one called
"purchases";
2. Your `mail.catchall.domain` is ``alice.example.com``;
3. Bob sends an email, as a reply to a sale but sends it with ``To:
purchases@bob.example.com, sales@alice.example.com``;
4. Odoo interprets wrongly that this email is a new record for "purchases"
alias although it was just an additional external recipient;
It should have been considered as a reply to "sales" as "purchases" does not
belong to the domain.
BOUNCE / ALIAS
==============
Same kind of issues may occur notably with bounce alias that should be
handled like other aliases, aka restricted to owned catchall domain.
Concerning bounce alias: try to find bounce recipients not only on the
first recipients but on all recipients.
Alias forward is checked also only on first recipient. It means that if
a reply's first recipient is an alias of another model, it is considered
as a forward to that alias and not a reply to the current thread. We think
that all recipients should be checked instead of just the first one as order
has no real meaning in emails.
WRITE TO CATCHALL
=================
Scenario
1. Have a catchall alias defined as ``alice``;
2. Have an alias defined as ``alice.sales`` for sales;
3. Receive an email for ``alice.sales@mydomain``: it is considered as writing
to catchall as condition is "catchall in email_to_localpart";
3. bis Receive an email for ``alice@mydomain, valid_alias@mydomain": it is
considered as writing to catchall as only first recipient is taken
into account;
A mail should be considered as a direct write to catchall only if all
recipients strictly match the catchall email (left-part and domain being
the catchall domain).
SPECIFICATIONS
==============
Alias check should be done only for emails linked to the catchall domain.
External addresses should not conflict with aliases. Moreover all recipients
should always be checked, not only the first one (aka, from email_to_localpart
to email_to_localparts as we now check local parts of all recipients).
Update mail_thread routing code in mail and also in mass mailing accordingly.
Add some tests to ensure it effectively works.
With this patch, these problems should not happen anymore. Tests are added
for those scenarios.
Closes PR #38459 (original 11.0 version)
Closes PR #38484 (12.0 version of this one)
Closes PR #40442 (final 11.0 version)
Fixes #34777
Fixes #39783
@Tecnativa TT20034
closes odoo/odoo#40737
Signed-off-by:
Thibault Delavallee (tde) <tde@openerp.com>
Showing
- addons/mail/models/mail_thread.py 22 additions, 11 deletionsaddons/mail/models/mail_thread.py
- addons/mass_mailing/models/mail_thread.py 7 additions, 2 deletionsaddons/mass_mailing/models/mail_thread.py
- addons/test_mail/tests/test_mail_gateway.py 179 additions, 7 deletionsaddons/test_mail/tests/test_mail_gateway.py
Loading
Please register or sign in to comment