How to Purge Old Emails via CLI

This article details how an administrator can remove emails older than a specified date using the Command Line Interface.

Solution

Using the below purge commands will result in data removal. To avoid any data loss we strongly suggest that a full backup of the domain / account, on which the purge will be applied, should be performed before performing the purge procedure.

To use the purge commands, connect to the CLI interface:

telnet <axigen_ip_address> 7000
<login> user admin
<password> admin_user_pa$$w0rd
For a list of available commands, type HELP
+OK: Authentication successful
<#>


Here, in the general context you have the command:

PURGE public|account folders <foldername> [, <foldername>]* [<purgecondition>] - purge mails from specified folders of all users from all enabled domains

If you use the command at this level it will apply the purge on all the enabled domains and their accounts.


Example of running the command:

<#> PURGE account folders Trash,Spam BEFORE 3w

This will remove all the emails with the internal date older than three weeks.

You can also use this command at domain level, thus applying the command for all accounts in only that domain or at account level, thus applying the purge for that specific account.


Notes:

  1. There are some implicit constraints, applied by default, that are meant to prevent any accidental data loss. Any purge condition you use for this command will be applied after a logical & (AND) is made with the following implicit conditions:

    Purge folders = (Spam Trash)
    Purge condition = (BEFORE 2w)


    These can be edited on a domain level via the CLI domain context:

    <#> update domain domain.test
    <domain#> config adminlimits
     

    and the commands:

    SET [purgeConstraint <search criteria>] - set the implicit purge condition constraint
    SET [purgeFolders (list of purgeable folders)]

     
  2. In any context of the CLI interface, you can type help to obtain a list of all the available commands.