Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] mail: Ignore aliases for other domains #38484

Open
wants to merge 1 commit into
base: 12.0
from

Conversation

@Yajo
Copy link
Contributor

Yajo commented Oct 11, 2019

This is the forward-port of #38459. In v12 it affects the detection of whether someone is writing directly to the catchall address.

The fw-port is not direct and I needed this patch now, so I thought it would be helpful to publish it here too and save some time for you and your dear bots.

Original description

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 routes the incoming email to the "sales" alias, which should have been ignored because it doesn't even belong to your domain.

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 he's a joker and sends it with To: purchases@alice.example.com, sales@alice.example.com.
  4. Odoo interprets wrongly that this email is a new record for "purchases", when it could have safely interpreted it as a tricky-but-valid response to an existing "sales" record.

Note: without the patch for scenario A, scenario B can happen also if Bob replies with To: purchases@bob.example.com, sales@alice.example.com.

With this patch, these problems won't happen anymore.

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
@tde-banana-odoo @Tecnativa TT20034

@robodoo robodoo added the seen 🙂 label Oct 11, 2019
@pedrobaeza

This comment has been minimized.

Copy link
Collaborator

pedrobaeza commented Oct 11, 2019

AFAIK, mail.catchall.domain must be properly set in an environment where you want to use catchall address. This might be an improvement for working without it, but not sure if other side effects of not having it.

Copy link
Contributor Author

Yajo left a comment

Thanks @pedrobaeza. I think it makes sense to require having a proper mail.catchall.domain setting for running this code, but since it wasn't there before and this patch is for stable branches, I supported the case of not having it defined.

Maybe this method is called in a stack tree where this is required higher above and you're right that we can remove it.

I added a couple of comments to highlight what would be the change in case we require mail.catchall.domain. Let's wait to see what does the odoo say.

email_to_localparts = [
e.split('@', 1)[0].lower()
for e in (tools.email_split(email_to) or [''])
if not alias_domain or e.endswith('@%s' % alias_domain)

This comment has been minimized.

Copy link
@Yajo

Yajo Oct 11, 2019

Author Contributor
Suggested change
if not alias_domain or e.endswith('@%s' % alias_domain)
if e.endswith('@%s' % alias_domain)
rcpt_tos_localparts = [
e.split('@')[0].lower()
for e in tools.email_split(rcpt_tos)
if not alias_domain or e.endswith('@%s' % alias_domain)

This comment has been minimized.

Copy link
@Yajo

Yajo Oct 11, 2019

Author Contributor
Suggested change
if not alias_domain or e.endswith('@%s' % alias_domain)
if e.endswith('@%s' % alias_domain)
@nafex

This comment has been minimized.

Copy link
Contributor

nafex commented Nov 5, 2019

Hi @Yajo,
I have tried this patch on 13.0 and it's causing an issue if you are using a catch all mailbox:
#39783

I don't know if this is an issue related only to my email server (mailcow) or not.

In my case the catchall_alias is always in email_to_localparts.

In the the email header Delivered-To always holds the catchall address (catchall@alice.example.com) and To holds the alias (support@alice.example.com). So catchall@alice.example.com is always in email_to_localparts and all emails to an alias are bounced...

@Yajo

This comment has been minimized.

Copy link
Contributor Author

Yajo commented Nov 6, 2019

Yes, this FW port is buggy as I discovered in a test in #38459. I have to update it.

@Yajo Yajo force-pushed the Tecnativa:12.0-mail-ignore_aliases_for_other_domains branch from 938d2d9 to 54d1c9a Nov 6, 2019
@Yajo

This comment has been minimized.

Copy link
Contributor Author

Yajo commented Nov 6, 2019

Try now.

@Yajo Yajo force-pushed the Tecnativa:12.0-mail-ignore_aliases_for_other_domains branch from 54d1c9a to 7399649 Nov 6, 2019
@robodoo robodoo added the CI 🤖 label Nov 6, 2019
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Nov 19, 2019
…ing aliases

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.

Same king of issues may occur notably with bounce alias that should be
handled like other aliases, aka restricted to owned catchall domain.

With this patch, these problems should not happen anymore. Tests are added
for those scenarios.

Closes PR odoo#38459 (original 11.0 version)
Closes PR odoo#38484 (12.0 version of this one)
Closes PR odoo#40442 (final 11.0 version)

@Tecnativa TT20034
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Nov 19, 2019
…ing aliases

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.

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).

With this patch, these problems should not happen anymore. Tests are added
for those scenarios.

Closes PR odoo#38459 (original 11.0 version)
Closes PR odoo#38484 (12.0 version of this one)
Closes PR odoo#40442 (final 11.0 version)

@Tecnativa TT20034
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Nov 19, 2019
…ing aliases

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.

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).

With this patch, these problems should not happen anymore. Tests are added
for those scenarios.

Closes PR odoo#38459 (original 11.0 version)
Closes PR odoo#38484 (12.0 version of this one)
Closes PR odoo#40442 (final 11.0 version)

@Tecnativa TT20034
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Nov 19, 2019
…ing aliases

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.

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 odoo#38459 (original 11.0 version)
Closes PR odoo#38484 (12.0 version of this one)
Closes PR odoo#40442 (final 11.0 version)

@Tecnativa TT20034
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Nov 19, 2019
…ing aliases

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.

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 odoo#38459 (original 11.0 version)
Closes PR odoo#38484 (12.0 version of this one)
Closes PR odoo#40442 (final 11.0 version)

@Tecnativa TT20034
robodoo pushed a commit that referenced this pull request Nov 19, 2019
…ing aliases

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.

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)

@Tecnativa TT20034

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Nov 21, 2019
…hecking aliases

This is a manual forward-port of 320ecc3 and 383d2fd
done in 11.

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.

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 odoo#38459 (original 11.0 version)
Closes PR odoo#38484 (12.0 version of this one)
Closes PR odoo#40442 (final 11.0 version)
Closes PR odoo#40442 (saas-11.3 fwd port)

@Tecnativa TT20034
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Nov 21, 2019
…hecking aliases

This is a manual forward-port of 320ecc3 and 383d2fd
done in 11.

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.

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 odoo#38459 (original 11.0 version)
Closes PR odoo#38484 (12.0 version of this one)
Closes PR odoo#40442 (final 11.0 version)
Closes PR odoo#40442 (saas-11.3 fwd port)

@Tecnativa TT20034
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Nov 21, 2019
…hecking aliases

This is a manual forward-port of 320ecc3 and 383d2fd
done in 11. It also includes direct write to catchall check improvement
according to other changes done in this commit.

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 odoo#38459 (original 11.0 version)
Closes PR odoo#38484 (12.0 version of this one)
Closes PR odoo#40442 (final 11.0 version)
Closes PR odoo#40442 (saas-11.3 fwd port)

@Tecnativa TT20034
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Nov 22, 2019
…hecking aliases

This is a manual forward-port of 320ecc3 and 383d2fd
done in 11.

/!\ It contains some additional content /!\
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 odoo#38459 (original 11.0 version)
Closes PR odoo#38484 (12.0 version of this one)
Closes PR odoo#40442 (final 11.0 version)
Closes PR odoo#40442 (saas-11.3 fwd port)

@Tecnativa TT20034
robodoo pushed a commit that referenced this pull request Nov 22, 2019
…hecking aliases

This is a manual forward-port of 320ecc3 and 383d2fd
done in 11.

/!\ It contains some additional content /!\
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)
Closes PR #40442 (saas-11.3 fwd port)

@Tecnativa TT20034

closes #40515

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
fw-bot added a commit to odoo-dev/odoo that referenced this pull request Nov 22, 2019
…hecking aliases

This is a manual forward-port of 320ecc3 and 383d2fd
done in 11.

/!\ It contains some additional content /!\
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 odoo#38459 (original 11.0 version)
Closes PR odoo#38484 (12.0 version of this one)
Closes PR odoo#40442 (final 11.0 version)
Closes PR odoo#40442 (saas-11.3 fwd port)

@Tecnativa TT20034
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Nov 25, 2019
…hecking aliases

This is a manual forward-port of 320ecc3 and 383d2fd
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 odoo#38459 (original 11.0 version)
Closes PR odoo#38484 (12.0 version of this one)
Closes PR odoo#40442 (final 11.0 version)
Fixes odoo#34777
Fixes odoo#39783

@Tecnativa TT20034
robodoo pushed a commit that referenced this pull request Nov 25, 2019
…hecking aliases

This is a manual forward-port of 320ecc3 and 383d2fd
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 #40737

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
fw-bot added a commit to odoo-dev/odoo that referenced this pull request Nov 25, 2019
…hecking aliases

This is a manual forward-port of 320ecc3 and 383d2fd
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 odoo#38459 (original 11.0 version)
Closes PR odoo#38484 (12.0 version of this one)
Closes PR odoo#40442 (final 11.0 version)
Fixes odoo#34777
Fixes odoo#39783

@Tecnativa TT20034

X-original-commit: 40ae36b
fw-bot added a commit to odoo-dev/odoo that referenced this pull request Nov 25, 2019
…hecking aliases

This is a manual forward-port of 320ecc3 and 383d2fd
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 odoo#38459 (original 11.0 version)
Closes PR odoo#38484 (12.0 version of this one)
Closes PR odoo#40442 (final 11.0 version)
Fixes odoo#34777
Fixes odoo#39783

@Tecnativa TT20034

X-original-commit: 40ae36b
@robodoo robodoo removed the CI 🤖 label Nov 29, 2019
@pedrobaeza pedrobaeza force-pushed the Tecnativa:12.0-mail-ignore_aliases_for_other_domains branch from 4eb2b75 to 213fcef Dec 2, 2019
tde-banana-odoo added a commit to odoo-dev/odoo that referenced this pull request Dec 9, 2019
…hecking aliases

This is a manual forward-port of 320ecc3 and 383d2fd
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 odoo#38459 (original 11.0 version)
Closes PR odoo#38484 (12.0 version of this one)
Closes PR odoo#40442 (final 11.0 version)
Fixes odoo#34777
Fixes odoo#39783

@Tecnativa TT20034

X-original-commit: 40ae36b
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 routes the incoming email to the "sales" alias, which should have been ignored because it doesn't even belong to your domain.

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 he's a joker and sends it with `To: purchases@alice.example.com, sales@alice.example.com`.
4. Odoo interprets wrongly that this email is a new record for "purchases", when it could have safely interpreted it as a tricky-but-valid response to an existing "sales" record.

Note: without the patch for scenario A, scenario B can happen also if Bob replies with `To: purchases@bob.example.com, sales@alice.example.com`.

With this patch, these problems won't happen anymore.

@Tecnativa TT20034
@pedrobaeza pedrobaeza force-pushed the Tecnativa:12.0-mail-ignore_aliases_for_other_domains branch from 213fcef to 562c815 Dec 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.