MAIL-EXPIRE(1)

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

SYNOPSIS

mail-expire AGE-IN-DAYS FILES...

DESCRIPTION
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 archive the highest 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.

OPTIONS
mail-expire recognizes the following options:

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

-t DIR
    Specifies a different target directory for storing expired mailbox files. Default is the current directory.

-T FILEBASE
    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.

--sfx-fmt FORMAT
    Format string, see strftime or date manpage.

--dry-run, -n
    Only examine input files and directories, no mail data is moved around.

--delete, -d
    Drop the old messages. No backup will be made, be careful with this option.

--keep, -k
    Copy the expired messages to output files and keep them in the input file.

--purge=VALUE, -p VALUE
    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.

-v LEVEL
    Verbosity level, where 0 produces no output except for errors, 1 some progress messages, 2 and more verbose progress messages.

-c output-shell-command
    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.

-X  Shortcut for -c and -s options, compressing with XZ compressor (multiple threads) and .xz file suffix.

-Z  Shortcut for -c and -s options, compressing with Zstandard compressor (zstd or zstdmt where available) and .zstd file suffix.

-U  Shortcut for -c and -s options, to not compress the output and not have an additional suffix.

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

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