Skip to content
JEWEL AHMMED edited this page Oct 25, 2017 · 3 revisions

ViMbAdmin V3 has a new feature - the ability to delete mailboxes on the filesystem.

When you delete (more correctly known as purge) a mailbox, it will also delete all associated aliases and remove that mailbox as a destination in aliases with multiple destinations.

On the Purge Mailbox page, there is a checkbox that is checked by default:

[*] Delete the home directory and mailbox files also

When this is checked, the mailbox is purged as normal but:

  • the mailbox entry is left in the database;
  • this entry is marked as delete_pending which means:
    • it won't show up in the mailbox list or the mailbox search;
    • it won't be included as part of the number of mailboxes;
  • and it will be marked as inactive and so will not accept any emails.

This feature must be explicitly enabled by setting the following in application.ini:

mailbox_deletion_fs_enabled = true

Deleting the Mailboxes

First ensure you have configured the following in application.ini:

binary.path.rm_rf     = "/bin/rm -rf"

You now need a cron job. This doesn't need to be executed too frequently as there is typically no panic on deleting mailboxes.

15 3 * * *    vmail   $INSTALL_PATH/bin/vimbtool.php -a mailbox.cli-delete-pending

where $INSTALL_PATH is the path to where you installed ViMbAdmin.

Warnings!

As we are executing an rm -rf here:

  • run as the appropriate virtual mail user (e.g. vmail) and not root;
  • ensure you are using dedicated home and mail directories for your users in a hierarchy where their home directories and mail directories are at the end.

The default structure is:

/path/to/storage/$domain/$local_part_home_directory/$mail_directory

Let's take an example using test@example.com - that would be stored as:

/path/to/storage/example.com/test/mail
                             \--/ \--/
                              |    |
                              |    |
       home directory --------+    |
       mail directory -------------+

The CLI command above acts by:

  • first rm -rf'ing /path/to/storage/example.com/test/mail;
  • then rm -rf'ing /path/to/storage/example.com/test.