Skip to main content

mailsort

Python package codecov Code style: black

Assign labels to emails on any IMAP mail server based on their similarity to other emails already assigned to the same label.

mailsort connects to a mail account over plain IMAP, trains a machine learning model on the labels (IMAP folders) you have already assigned, and uses that model to suggest or apply labels to new messages. It has no dependency on Google APIs - for Gmail-specific features (OAuth, the Gmail label API, the sorting daemon and web UI) see gmailsorter, which depends on mailsort for the shared IMAP and machine learning core.

Installation

pip install mailsort

Command line interface

mailsort --host imap.example.com --username user@example.com --password "..." -u
mailsort --host imap.example.com --username user@example.com --password "..." -l "some_label"

The IMAP password is provided with --password, e.g. by having your shell pull it from a password manager.

Python interface

from mailsort import Imap

imap = Imap(
    host="imap.example.com",
    port=993,
    username="user@example.com",
    password="...",
    connection_str="sqlite:///email.db",
)
imap.update_database(quick=False)
imap.fit_machine_learning_model_to_database()
imap.filter_messages_from_server(label="some_label", recommendation_ratio=0.9)

Metadata

Release files for mailsort 0.0.2

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

Source distribution (sdist)

Source distribution for mailsort 0.0.2
File Size Uploaded
mailsort-0.0.2.tar.gz 20.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mailsort 0.0.2
File Interpreter ABI Platform
mailsort-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 45.0 kB

Release files / mailsort-0.0.2.tar.gz

Download URL mailsort-0.0.2.tar.gz
Size 20.8 kB
Tags Source
SHA-256 checksum
How to use checksums
df55c7ab41cd68bb2afa7dcb18019616b1dd7bc0c940e9b99737b16653f5fa6d
BLAKE2b-256 checksum
How to use checksums
a8820d6020b367547849d2f601c6c6d9ed71792dd8778d6786a9c0a12ea7ae82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 19, 2026.

Transparency log

Release files / mailsort-0.0.2-py3-none-any.whl

Download URL mailsort-0.0.2-py3-none-any.whl
Size 24.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f4ffe233f82f36e52776e463e8789f531168e0482b174b8c04d0f711dcae9274
BLAKE2b-256 checksum
How to use checksums
35ca4faa55ae0e862930d3c1dd0e3297a6a264fd76b87923c68407aae18fe321
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 19, 2026.

Transparency log

Release history Release notifications | RSS feed

0.0.3

2 release files

This release

0.0.2 This release

2 release files

0.0.1

2 release files

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