Skip to main content

A utility to compress email messages for use with dovecot.

Project description

Compress mail

PyPI - Version PyPI - Python Version

blog X (formerly Twitter) Follow

compress-mail is a simple command line tool that is used with Dovecot to compress Maildir format files.


Table of Contents

Introduction

compress-mail is a simple command line tool that is used with Dovecot to compress Maildir format files.

It follows Dovecot best practices, including its own implementation of the maildirlock program, originally written in C and that is buggy. The Dovecot authors suggest using dsync (doveadm sync), but this only does whole mailboxes, not individual folders, and is more time consuming to configure.

compress-mail uses Maildir flags to mark which files have already been compressed, and thus skips them on subsequent runs, so it is safe to run multiple times.

It will also skip anything that doesn't have the S= size flag. The reasoning is from the Dovecot authors, who say:

All mails must have ,S=<size> in their filename where contains the original uncompressed mail size, otherwise there will be problems with quota calculation as well as other potential random failures. Note that if the filename doesn't contain the ,S=<size> before compression, adding it afterwards changes the base filename and thus the message UID. The safest thing to do is simply to not compress such files.

I found that if I just move those mails to a temp folder and back again in a MUA (like Thunderbird), it will automatically add the ,S=<size> to the filenames.

Installation

The recommended way to install compress-mail is to use pipx.

After getting pipx installed, simply run:

pipx install compress-mail

Please don't use pip system-wide.

You can of course also install it using classic virtualenvs.

Usage

Usage help can be obtained by running compress-mail --help.

If you have a normal Maildir structure like the following:

drwx------ 2 user group  2363392 Mar 31 08:42 cur
-rw------- 1 user group   242824 Mar 30 15:41 dovecot.index
-rw------- 1 user group 15596760 Mar 31 08:18 dovecot.index.cache
-rw------- 1 user group    26224 Mar 31 08:42 dovecot.index.log
-rw------- 1 user group       97 Feb 15  2019 dovecot-keywords
-rw------- 1 user group   953295 Mar 31 08:18 dovecot-uidlist
-rw------- 1 user group        0 Mar  2  2011 maildirfolder
drwx------ 2 user group    36864 Mar 31 08:17 new
drwx------ 2 user group   270336 Mar 31 08:18 tmp

.Trash
├── cur
├── new
└── tmp

All you need to do is run:

user@host:~$ compress-mail --basedir .Trash --compression zstd

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

compress_mail-1.0.9.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

compress_mail-1.0.9-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file compress_mail-1.0.9.tar.gz.

File metadata

  • Download URL: compress_mail-1.0.9.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for compress_mail-1.0.9.tar.gz
Algorithm Hash digest
SHA256 8d30fe5265dc8ce5bbc5f39273a05b2973e9a9b02638d5bbe5ad354a5011288c
MD5 cda41ae63620ef018bbb33927886158e
BLAKE2b-256 8a614484a69bd3d8378498e94ce8fb7bb5d83d72e6d661a1656eee00aafad392

See more details on using hashes here.

File details

Details for the file compress_mail-1.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for compress_mail-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 cf56da1170d9856f81a000adf9a39c43a8475682ddd491d92b676ca056159af5
MD5 54300338202e023ecf953402a59a0b53
BLAKE2b-256 e37a3fd250dc4c2462f34457679c2a4fd924448bd22a3805d44c706963c9242f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page