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/… exemplo.com.br after 14 days:

aox delete mail 14 address exemplo.com.br

The next example has both a mailbox and a search:

aox delete mail 90 /archive/sales address exemplo.com.br

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 info@aox.org.

Relevant links

About this page

Last modified: 2010-11-19
Location: aox.org/aox/deletemessages