DOKK / manpages / debian 12 / mail-expire / mail-expire.1.en
MAIL-EXPIRE(1) User Commands MAIL-EXPIRE(1)

mail-expire - program to extract outdated messages from mbox files

mail-expire is a small utility which only purpose is to help on keeping the size of multiple mail folders as small as needed (by removing outdated messages).

Maildir and Mailbox formats are supported for input, both types are mentioned interchangeably in this manual page. Output goes to Mailbox files.

The old messages are compressed with gzip or xz and stored in the file with the name following the pattern MBOXNAME.MONTH_YEAR.gz (or similar). The reference time for the output filename is calculated from the current time minus number of days specified in the first parameter.

If a file of the same name is found, the default storage strategy is appending a new compressed region to the existing file (unless -u option is used). This allows, for example, to run the expiration in a cron job each weekend, while collecting all mails from (roughly) each month into dedicated buckets. The drawback of this appending mode is a slightly reduced compression ratio, the advantage is reduced disk usage all the time. Also, such archives can later be recompressed separately to achive the highst compression ratio (like: "mv x.xz x.old.xz && xzcat x.old.xz | xz -9 > x.xz && rm xz.old.xz").

SPACE REQUIREMENTS

For Mbox input, additional disk space to store the amount of fresh messages plus a portion of the size of expired messages (depending on the output compression).

For Maildir input, only additional space for a portion of the size of expired messages (depending on the output compression) is required.

mail-expire recognizes the following options:

If an existing archive file with the expected filename is found, another filename is to be chosen. This happens by appending a suffix like (NUMBER) to the basename.

This is a legacy option, not compatible with any custom output command.

Specifies a different target directory for storing expired mailbox files. Default is the current directory.
Explicit output target file name for all inputs (i.e. merging all expired mails into the same target mbox). This mostly disables automated name generation (base name and date suffix), only the compression suffix (-c option and related) is appended.
Only examine input files and directories, no mail data is moved around.
Drop the old messages. No backup will be made, be careful with this option.
Copy the expired messages to output files and keep them in the input file.
Specify how to remove input files or folders after becoming empty. 0: never remove, 1 (default): remove empty files but keep folders (also related folders), 2: remove empty Mbox file and Maildir, 3: like 2 but also remove the input file if it was empty.
Verbosity level, where 0 produces no output except for errors, 1 some progress messages, 2 and more verbose progress messages.
A shell script fragment which is run in order to archive the data. Default or current value can be displayed with -v2 option.

This command is very delicate, it might destroy the target file. It might also be suspicious to shell injection attacks, quotes are important.

Shortcut for -c and -s options, compressing with XZ compressor (multiple threads) and .xz file suffix.
Shortcut for -c and -s options, to not compress the output and not have an additional suffix.
Lockless operation, input Mailboxes are assumed to be not touched by other tools while mail-expire runs. By default, it attempts to mimic the behavior of procmail to prevent it from file modifications. This option has no effect on Maildir type input. To be used with care, runtime conflicts with procmail or other tools MIGHT CAUSE DATA LOSS.

This manual page was written by Eduard Bloch. Permission is granted to use, copy, distribute and/or modify this document under the terms of the MIT license.

2021-01-01 mail-expire 0.9.1