Skip to content

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

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

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

@skanndar
skanndar force-pushed the 19.0-fix-mail_tracking-corecipient-bounce branch from 6079aa8 to 0b400fa Compare October 7, 2026 14:44
…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.

Assisted-by: Claude Opus 5.5
@skanndar
skanndar force-pushed the 19.0-fix-mail_tracking-corecipient-bounce branch from 0b400fa to 721cb3f Compare December 1, 2026 19:51
@skanndar

skanndar commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Closing: the shared status comes from the recipient of the trackings, which is the same for all of them when mail_composer_cc_bcc puts the whole To list in every email. With mail_tracking alone, each tracking has its own recipient.

@skanndar skanndar closed this Dec 1, 2026
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