Skip to main content

Mail Deduplicate

Last release Python versions Downloads Unittests status Documentation status DOI

What is Mail Deduplicate?

Provides the mdedup CLI, an utility to deduplicate mails from a set of boxes.

The mdedup command line and the first steps of a run merging two archives

Features

  • Duplicate detection based on cherry-picked and normalized mail headers.
  • Presets: a conservative one that only treats identical mails as copies, to run on every box before tuning anything, and an aggressive one that trusts Message-ID alone.
  • Fetch mails from multiple sources.
  • Reads and writes to mbox, maildir, babyl, mh, mmdf and eml formats.
  • Deduplication strategies based on size, timestamp, file path or quantity, chainable as fallbacks.
  • Copy, move, delete or hardlink the resulting set of duplicates.
  • Dry-run mode.
  • Protection against false-positives with safety checks on size and content differences. Two mails sharing every hashed header but not their body are left alone, while their real duplicate is acted on, here by mdedup --strategy discard-matching-path --regexp old --action delete-discarded --dry-run new.mbox old.mbox: A dry run deleting one duplicate and skipping a set of two different mails
  • Optional cache reusing the hashes computed by previous runs.
  • Parallel hashing and selection over several processes.
  • Supports macOS, Linux and Windows.
  • Standalone executables for Linux, macOS and Windows.
  • Shell auto-completion for Bash, Zsh and Fish.

Installation

All installation methods are available in the documentation. Below are the most popular ones:

Try it now

uv is the fastest way to run mdedup on any platform, thanks to its uvx command:

$ uvx --from mail-deduplicate -- mdedup

macOS

mdedup is part of the official Homebrew default tap, so you can install it with:

$ brew install mail-deduplicate

Executables

Standalone binaries of mdedup's latest version are available as direct downloads for several platforms and architectures:

Platform arm64 x86_64
Linux Download mdedup-linux-arm64.bin Download mdedup-linux-x64.bin
macOS Download mdedup-macos-arm64.bin Download mdedup-macos-x64.bin
Windows Download mdedup-windows-arm64.exe Download mdedup-windows-x64.exe

Quickstart

Duplicate mails pile up whenever boxes get copied around: backups of the same account taken at different times, per-folder exports where a mail tagged with several labels lands in several boxes, archives consolidated from multiple clients, or IMAP synchronizations gone wrong.

mdedup cleans this up. Start with a conservative pass over all your boxes: --preset conservative treats as copies only the mails whose bytes are identical, keeps one copy of each, and writes every mail that survives into a brand new box. The sources are only read, so there is nothing to rehearse:

$ mdedup --preset conservative --export merged.mbox 2024.mbox 2025.mbox

A conservative first pass merging two archives

Copies that differ somewhere, by a header a mailing list added or a Re: prefix, are left in place. mdedup catches those with its default hashing: it groups copies of the same mail by hashing a curated set of normalized headers, applies a --strategy to pick which copy to keep in each group, then performs an --action on the result. The default action is the safest one: sources are only read, and the deduplicated selection is written to a brand new box.

So to merge the same two archives into a single clean box, keeping the copy each mail has in the older one:

$ mdedup --strategy select-matching-path --regexp 2024 --export merged.mbox 2024.mbox 2025.mbox

Mails found in both archives are copied once into merged.mbox, along with all the mails that were unique to each source. Backups usually leave copies byte-identical, which no date or size strategy splits apart: select-one then keeps one copy of each mail, the one whose path sorts first.

A whole mdedup run, ending on its two report tables

To remove duplicates in place instead, switch to a destructive action, and rehearse with --dry-run:

$ mdedup --strategy select-matching-path --regexp 2024 --action delete-discarded --dry-run 2024.mbox 2025.mbox

The trail names each mail the run would delete, and alters nothing.

A mdedup dry run on the two archives

The hands-on tutorial builds a small playground of duplicated mails, then walks through strategies, actions and safeguards on it. The design page explains how duplicates are detected.

You can support this project with pull requests, business support 🤝 and sponsorship 🫶.

Metadata

Release files for mail-deduplicate 9.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mail-deduplicate 9.6.0
File Size Uploaded Provenance Actions
mail_deduplicate-9.6.0.tar.gz 164.0 kB With provenance Details for mail_deduplicate-9.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mail-deduplicate 9.6.0
File Interpreter ABI Platform Actions
mail_deduplicate-9.6.0-py3-none-any.whl Python 3 none any Details for mail_deduplicate-9.6.0-py3-none-any.whl

Total release size: 257.3 kB

Release files / mail_deduplicate-9.6.0.tar.gz

Download URL mail_deduplicate-9.6.0.tar.gz
Size 164.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9bca8c396d62c7adf61e0f3c3fd12b3818c52df6f06aa9c86262a0e99c762116
BLAKE2b-256 checksum
How to use checksums
6b921ca219adac449af52e072853092d8e315da97c102ad77651a8c56877caac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Release files / mail_deduplicate-9.6.0-py3-none-any.whl

Download URL mail_deduplicate-9.6.0-py3-none-any.whl
Size 93.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9f95feb7a3d7e5399475b6df8e9fad49d9955f2b02911db151002977966fb198
BLAKE2b-256 checksum
How to use checksums
65c49f4fabb36ae7d31b54bb1b1a8ae7280789ecb263b362ebb98a19744ce9f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

Security for mail-deduplicate 9.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mail_deduplicate-9.6.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

9.6.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page