Updated: September 4, 2024
Managing large volumes of emails on Axigen may require purging old messages to free up disk space, prevent performance issues, or maintain mailbox quotas. By default, the purge function only works for the Spam and Trash folders, but it can be extended to the Inbox or other folders and automated for efficiency. This article will show you how to configure and run purges via CLI and automate the process with scripting.
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.
Read on for the steps you need to take to purge old emails.
Step 1: Connect to the CLI
Open a terminal and connect to the Axigen CLI:
telnet <axigen_ip_address> 7000
Step 2: Authenticate as an Admin
Log in using admin credentials:
<login> user admin
<password> admin_user_pa$$w0rd
Step 3: Configure the Inbox as a Purgeable Folder
To purge emails from the Inbox, first configure it as a purgeable folder:
update domain yourdomain.com
config adminlimits
set purgefolders ("Deleted Items" Spam Trash Inbox)
commit
back
Be careful when modifying purgeable folders. It is recommended to leave the default configuration unless necessary. By default, messages in “Spam” and “Trash” are automatically deleted after 30 days.
Step 4: Purge Emails from a Specific User’s Folder(s)
Once configured, you can purge emails from specific folders. First, navigate to the user’s account:
update domain yourdomain.tld
update account user@yourdomain.tld
Single Folder Purge Example
To purge emails older than 2 weeks from the Inbox:
purge account folders Inbox BEFORE 2w
To purge emails older than 1 day from the Inbox:
purge account folders Inbox BEFORE 1d
Multiple Folder Purge Example
To purge emails older than 6 months from both Inbox and Sent:
purge account folders Inbox,Sent BEFORE 26w
To purge emails older than 1 day from Inbox and Trash:
purge account folders Inbox,Trash BEFORE 1d
Be cautious when using the purge command. If no specific time period is mentioned, the default purge condition (BEFORE 2w) will apply.
Step 5: Purge Emails for All Users in a Domain (Use with Caution)
To purge emails for all users in a domain, navigate to the domain level:
update domain yourdomain.tld
Then, purge the emails for all users:
To purge emails older than 6 months from the Inbox and Sent:
purge account folders Inbox,Sent BEFORE 26w
To purge emails older than 6 months from the Inbox and Trash:
purge account folders Inbox,Trash BEFORE 1d
Test on non-production accounts before running domain-wide purges to avoid data loss.
Step 6: Restore Default Purgeable Folders (Optional)
After purging, remove folders like Inbox from the purgeable folders list to avoid future accidental deletions:
update domain yourdomain.com
config adminlimits
set purgefolders ("Deleted Items" Spam Trash)
commit
back
Automating Purging via Scripting and APIs
You can automate the purging process using a script and schedule it via a cronjob, or use Axigen’s PHP CLI API or Python API for more advanced scripting. These methods allow you to integrate purge operations into your regular maintenance routines.
• Axigen PHP CLI API: Automate purge operations and more using PHP.
• Axigen Python API: A Python interface for scripting advanced mail server management.
Alternatively, you can send text-based commands over TCP to automate tasks using your language of choice.
Email Retention and Archiving
For email retention, consider using a dedicated solution like MailArchiva, which can be integrated with Axigen. This tool offers comprehensive email archiving, allowing you to retain important emails securely while managing storage needs.
As an alternative, you can also archive emails directly into a different mailbox within Axigen. This is a built-in feature that allows you to manage retention while keeping all archived emails within your Axigen environment. For more details, refer to this guide on email archiving with Axigen.
Conclusion
Purging old emails is a useful way to keep your mail server running smoothly and manage storage. Whether done manually or automated via scripting or APIs, it’s important to test purge commands in non-production environments to avoid mistakes. For email retention, you can integrate MailArchiva or use Axigen’s built-in mailbox archiving feature.