Deleting mail automatically

The aox delete mail command inserts or updates a mail retention policy. Messages matching the policy will be automatically deleted after the specified time.

Each policy has a duration, and optionally a mailbox to which it applies and/or a search specification.

If it applies to a mailbox, it also applies to all children of that mailbox. If you specify a search, then the policy applies only to messages that match that search, otherwise it applies to all messages.

The simplest policy is one that deletes all mail after one week:

aox delete mail 7

A little more complex is one that matches all messages in certain mailboxes, such as this example, which deletes mail in some mailboxes after ten years:

aox delete mail 3660 /archive

It is also possible to specify a search. This deletes all mail from/to/… after 14 days:

aox delete mail 14 address

The next example has both a mailbox and a search:

aox delete mail 90 /archive/sales address

Note that deletion policies don't override each other. If you specify that all should be deleted after one year and that mail in /archives should be deleted after two, then everything will be deleted after one year. The way to override the one-year policy is to use aox retain mail like this:

aox retain mail 721 /archives

The syntax used for the search is the same as for aox show search and aox retain mail. (The show search command is a convenient way to experiment with search syntax.)

In case of questions, please write to

Relevant links

About this page

Last modified: 2010-11-19