Regular maintenance

As emails are added and deleted it's good practice to check the database is in good order and remove emails that have been deleted.

dbmail-util is your friend.

DBMail is designed to be optimised to be fast and reliable, to achieve this there are no long running transactions that might cause a database lock and so there are checks to ensure the database is in good order.

Unless you are running a very large system, the following is a good monthly task:

dbmail-util --all-checks

To be able to recover emails deleted in error, there is a two step process, first deleted emails are marked for deletion, then second they are purged from the database. If you run this monthly then you leave a window of a month when deleted emails can be recovered.

--all-checks should be run once per maintenance period, it first purges messages with a status of deleted, then sets the deleted status for messages flagged for deletion.

As emails are checked as they enter DBMail it's unusual for an invalid email to be found in the database, but for historic reasons there are checks for message integrity, checks for caching body/header/envelope and empty caches, dangling/invalid aliases and forwards.

Database maintenance

All databases need regular maintenance, see your database documentation for further guidance.