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

[17.0] mail_tracking starting endless email loop #1414

Open
Bart-dh opened this issue Jul 8, 2024 · 4 comments
Open

[17.0] mail_tracking starting endless email loop #1414

Bart-dh opened this issue Jul 8, 2024 · 4 comments
Labels

Comments

@Bart-dh
Copy link

Bart-dh commented Jul 8, 2024

module: mail_tracking
version: 17.0 EE
Odoo.sh hosting

  • Case: custom domain and custom alias domain, e.g. 'test.com'
  • web.base.url set to 'test.com' and web.base.url.freeze param set
  • alias domain is 'test.com'
  • catchall address is '[email protected]'

For some reason unknown to me, at some point when sending an email, [email protected] gets added as recipient, resulting in the sent mail returning to Odoo immediately, and starting an endless email loop. A client of ours sent 21k emails this weekend to a supplier because of this loop.

Note that the reply-to is [email protected] instead of [email protected], so I don't know where the default catchall comes from. I have noticed that the module also adds extra suggested recipients though, so maybe this is related.

I have no proof that this module caused the issue, other than it started after installation, and does not happen anymore after deinstallation.

@Bart-dh Bart-dh added the bug label Jul 8, 2024
@Bart-dh
Copy link
Author

Bart-dh commented Jul 8, 2024

@chienandalu

@chienandalu
Copy link
Member

Hi, @Bart-dh

It could be that the original mail had that [email protected] in the extra recipients, which are added to the suggested recipients for the message replies:

def _message_get_suggested_recipients(self):
"""Adds email 'extra' recipients as suggested recipients.
If the recipient has a res.partner, use it.
"""
res = super()._message_get_suggested_recipients()
self._add_extra_recipients_suggestions(res, "email_cc", _("Cc"))
self._add_extra_recipients_suggestions(res, "email_to", _("Anon. To"))
return res

We try to dectect the existing aliases:

aliases = self.env["mail.alias"].get_aliases()

In order to discard them

if not partner_id:
if email not in aliases:
self._message_add_suggested_recipient(
suggestions, email=email, reason=reason
)

This is where we retrieve them (in v17 there's a new way to set the catchall with the mail.alias.domain records that allow multi-domain catchalls):

@api.model
@tools.ormcache()
def get_aliases(self):
"""We want to discard these addresses for trackings"""
aliases = {
x["display_name"]
for x in self.search_read([("alias_name", "!=", False)], ["display_name"])
}
mail_alias_domain = self.env["mail.alias.domain"].search([])
catchall_emails = set(mail_alias_domain.mapped("catchall_email"))
default_from_emails = set(
mail_alias_domain.filtered("default_from").mapped("default_from_email")
)
return aliases | catchall_emails | default_from_emails

Also check if a partner could have that catchall email set, as it could be that is assigning it directly:

partners_info = self.sudo()._message_partner_info_from_emails(email_extra_list)
for pinfo in partners_info:

@Bart-dh
Copy link
Author

Bart-dh commented Jul 25, 2024

@chienandalu what is the reason for adding extra suggested recipients? To me it looks like extra functionality which is irrelevant to the rest of this module, but I could be mistaken

@pedrobaeza
Copy link
Member

It's inside the scope, as Odoo is not considering CC unless a contact matching the email address exists, and this module does it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants