Skip to content

Add recipient-aware Message-ID deduplication - #491

Open
iafred-bot wants to merge 1 commit into
jsuto:masterfrom
iafred-bot:recipient-aware-deduplication
Open

Add recipient-aware Message-ID deduplication#491
iafred-bot wants to merge 1 commit into
jsuto:masterfrom
iafred-bot:recipient-aware-deduplication

Conversation

@iafred-bot

@iafred-bot iafred-bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR adds an optional recipient-aware Message-ID deduplication mode.

By default, Piler keeps its current behavior: duplicate detection is based on Message-ID only. When enabled with:

deduplicate_messages_by_recipient=1

or, in the Docker entrypoint:

DEDUPLICATE_MESSAGES_BY_RECIPIENT=1

a message is considered a duplicate only if an archived message already has the same Message-ID, the same stored sender, and the exact same recipient set.

Use case

When Piler receives an email addressed to a functional/shared mailbox, the initial message is archived correctly and the indexed fields match that first delivery.

On the final mail server hosting that functional mailbox, mailbox forwarding rules may expand the message to the final recipients. When those expanded deliveries come back to Piler, they can currently be treated as duplicates, probably because the Message-ID is unchanged, even though the recipient is no longer the same as in the original delivery.

The impact is that Piler may not archive those expanded deliveries, creating a blind spot for emails received by some users through functional mailbox forwarding.

Behavior

With deduplicate_messages_by_recipient=1:

  • same Message-ID, same sender, same exact recipient set: duplicate
  • same Message-ID, same sender, different recipient set: archived separately
  • same Message-ID, different sender: archived separately
  • if sender or recipients cannot be parsed, Piler falls back to the existing Message-ID-only behavior for that message

The default remains 0, so existing installations are unchanged unless they explicitly enable the option.

Validation

Tested on Debian 13 runner:

./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
make -j$(nproc)
./unit_tests/run.sh

The unit test suite passes, including the new recipient-aware duplicate detection cases.

Prepared by iafred-bot
GitLab: @fredbcode
GitHub: @fredbcode

@iafred-bot
iafred-bot requested a review from jsuto as a code owner August 24, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant