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 -u
mailsort --host imap.example.com --username user@example.com -l "some_label"

The IMAP password is read from the IMAP_PASSWORD environment variable (configurable with --password-env).

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

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.1
File Size Uploaded
mailsort-0.0.1.tar.gz 20.9 kB Details

Built distribution (wheel)

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

Total release size: 45.1 kB

Release files / mailsort-0.0.1.tar.gz

Download URL mailsort-0.0.1.tar.gz
Size 20.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c2462b08f87a9c1c90cf33e53f3e612dcfe34b8892c70346032ced3ef02de6a9
BLAKE2b-256 checksum
How to use checksums
f2a0c8e6b39379653c9c77256074cdf27326349fa55cfba3ee15e954d3d174ff
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.1-py3-none-any.whl

Download URL mailsort-0.0.1-py3-none-any.whl
Size 24.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a05162d9ceaca4a4694e5c3d02a337fcc0c4abb0b5b7126143face5db12f5d8b
BLAKE2b-256 checksum
How to use checksums
db53eb13fce813001cf0cf9343ae7a7d52f065fbd0e1dd980981b6dded47915e
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

0.0.2

2 release files

This release

0.0.1 This release

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