Skip to content

[19.0][FIX] mail_tracking: don't flag co-recipients as error on a single bounce - #286

Open
skanndar wants to merge 1 commit into
OCA:19.0from
skanndar:19.0-fix-mail_tracking-corecipient-bounce
Open

skanndar wants to merge 1 commit into
OCA:19.0from
skanndar:19.0-fix-mail_tracking-corecipient-bounce

Conversation

@skanndar

@skanndar skanndar commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Problem

In the chatter, the "To:" line (the MessageTracking template added by mail_tracking) marks a red ✖ error on every recipient when a message goes to several and only one bounces — as if nobody received it. Recipients without a tracking record show unknown. Core's own envelope icon / MessageNotificationPopover show the correct per-recipient status; only the mail_tracking line is wrong.

Root cause

mail.tracking.email tracks per SMTP send, not per recipient. When a message goes to several recipients and the DSN of one bounces, the bounce state (soft-bounced/bounced) is shared by the co-recipients' mail.tracking.email, so mail.message.tracking_status() returns status='error' for recipients that were actually delivered; recipients with no tracking fall to 'unknown'.

Fix

The core mail.notification is per recipient and reliable, so reconcile the per-send tracking status against it at the end of tracking_status():

  • core sent + tracking error/unknown → sent
  • core bounce/exception + tracking sent/unknown/waiting → error
  • delivered/opened (tracking-pixel info the core doesn't have) are left untouched.

Tests / reproduction

Regression test (test_corecipient_bounce.py) builds the real case: a message to four recipients, one really bounced (core bounce + tracking soft-bounced), two delivered but sharing the soft-bounced tracking, one delivered with no tracking. Verified A/B on odoo:19: before → all four error/unknown; after → only the real bounce is error, the other three sent.

Real-world sighting: a message to four recipients where one address did not exist (550 5.1.1 User unknown) showed all four as ✖.

…gle bounce

In the chatter the "To:" line (the MessageTracking template) marked a red error
on EVERY recipient when a message went to several and only ONE bounced, and
showed 'unknown' for recipients without a tracking record -- even though core's
own envelope icon showed the right per-recipient status.

mail.tracking.email tracks per SMTP send, not per recipient, so a bounce
(soft-bounced/bounced) is shared by the co-recipients' trackings and
mail.message.tracking_status() returns status='error' for recipients that were
actually delivered; recipients with no tracking fall to 'unknown'.

Reconcile the per-send tracking status against the core mail.notification, which
is per recipient and reliable: core 'sent' downgrades a tracking error/unknown
to 'sent'; core 'bounce'/'exception' upgrades a tracking sent/unknown/waiting to
'error'. 'delivered'/'opened' (tracking-pixel info the core does not have) are
left untouched.

Real case: a message to four recipients where one address did not exist
(550 User unknown) showed all four as error; after the fix only the real bounce
is error and the other three are sent.
@skanndar
skanndar force-pushed the 19.0-fix-mail_tracking-corecipient-bounce branch from 6079aa8 to 0b400fa Compare October 7, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants