Sometimes we get asked if the VPOP3 administrator can set up VPOP3 to automatically delete old messages from users’ mailboxes. While this is often a dubious thing to do, there are occasionally valid reasons for doing it. VPOP3 Enterprise has a ‘hidden’ facility to do this automatic deletion based on rules. At the moment there is no friendly user-interface for configuring it, but that will be added in the future. In the meantime, this article may help.
This article is for advanced users and you may trash your VPOP3 installation!
This article is only for VPOP3 Enterprise 5.0 or later. It does not work in VPOP3 Basic, or in earlier versions of VPOP3
The instructions in this article involve accessing the VPOP3 Enterprise database directly. There is plenty of opportunity to kill your VPOP3 installation if you do this, so take care! If you want us to set this up for you, we can if you have an active priority support contract, or purchase a support incident.
Full Details
First, decide on your rules, you have these options:
- <age>
- read
- unread
- flagged
- unflagged
- deleted
- spam
- size: <size>
- folder: <foldername>
30
That would delete any message older than 30 days in the inbox
A more complex rule might be:
30~read~folder:*~unflagged
This would delete any messages in any folder which have been read, have not been flagged (‘starred’) and are over 30 days old
or
60~read~folder:sent~size:10000000
This would delete any messages in ‘sent’ which have been read, are over 60 days old and are over 10000000 bytes in size
If you do not specify a ‘folder:’ value, it just applies to the ‘Inbox’.
Within a rule, every condition must be matched, so:
30~read
means the messages must be over 30 days old AND marked as read – *not* over 30 days old OR marked as read
If you want to have several different conditions, you can separate rules with ‘|’ characters, so:
180~read|60~read~size:10000000
will delete read messages over 180 days old, or read messages over 10,000,000 bytes after 60 days
You can set global rules, or rules which just apply to one user. If a user has their own rules, then ONLY those rules apply. If they have no rules, then the global rules apply. Note that a user rule of ” means do not do any pruning for that user, NOT use the global rules. Either the user ‘PruneRules’ value must not exist in the database at all, or it must be set to ‘default‘ to use the global rules.
Global Rules
To set global rules the first time, go to Settings -> Database -> Query.
Type: Insert into settings.settings values(name, value) values(‘PruneRules’, ‘<rules>’);
and press Do Query
To change the global rules, go to Settings -> Database -> Query.
Type: Update settings.settings set value='<new rules>’ where name=’PruneRules’;
and press Do Query
User Rules
User rules are a bit more complicated, because they are keyed on the user’s numeric ID, not their name
Go to Settings -> Database -> Query
Type: select * FROM users.users where username='<username>’;
and press Do Query
Take a note of the ‘usernumber’ value returned
Then type: Insert into users.usersettings (usernumber,dataname,datavalue) values(<usernumber>, ‘PruneRules’, ‘<rules>’);
(where you put the ‘usernumber’ you saw earlier instead of ‘<usernumber>’) and press Do Query
To update a rule, type: Update users.usersettings set datavalue='<new rules>’ where dataname=’PruneRules’ and usernumber=<usernumber>;
Testing
Test your rules carefully!
Note that VPOP3 will not prune the old messages immediately. It only checks these rules every 20 minutes or so (this time can vary wildly depending on what else it is having to do). If you look in the ‘Full Logging’ VPOP3.LOG file, you should see entries like ‘Prune message store for <username> (Rules:<rules>)’ when it is pruning a user’s mailbox – this won’t appear if no prune rules for that user are defined.
If you get the rule wrong, then VPOP3 may delete messages you don’t want it to delete. In that case, remove the rule (set it to ”), and use the ‘Recycle Bin’ functionality (User -> Edit -> Advanced) to recover the deleted messages