You are not logged in or registered. Please login or register to use the full functionality of this board...

Post Reply 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Managing orphaned Plesk mailboxes
04-03-2012, 01:58 PM
Post: #1
Managing orphaned Plesk mailboxes
There are two basic issues:

Users setup ‘redirects’ or ‘mail group’ functions and leave the account mailbox enabled, then never check the mailbox and delete the messages. (e.g. [email protected] forwards to [email protected] and [email protected], but nobody logs on to [email protected] and deletes the message)

Disabling the mailbox does not delete the existing files in the mailbox. All those mail files will just hang around forever, orphaned from the control panel.

Slogging around in the qmail directories looking for files is no fun. Here’s how I rid myself of these pesky disk-eaters. I took a two pronged approach:

Query the Plesk database to identify mail accounts with mailboxes that redirect.

Query the filesystem to find Mailbox directories that are large.

Query the Plesk Database

You’ll need shell access to your server. Login to your server, pop into mysql and use the Plesk database (PSA) using the following command:

mysql -u admin -p`cat /etc/psa/.psa.shadow`;
use psa;

Use the following query to select mailboxes that redirect:

select name,mail_name,redir_addr from mail, domains
where mail.dom_id = and postbox = 'true' and redirect = 'true';

Now you’ve got some ammunition. Exit out of mysql.

Finding Big Mailboxes

A ‘mailbox’ in qmail is simply a directory. Each undelivered message is a file in that directory. On my installation of Plesk qmail is installed in ‘/var/qmail/’ The mailbox for ‘[email protected]’ takes the form: ‘/var/qmail/’.

The command below uses ‘du’ to grab the size of all the directories in mailnames, grep filters out all but the ‘Maildir/new’ directory leaving us with a list of all our mailboxes and their size. Running them through sort in the manner shown orders them biggest to smallest. Just the way we want ‘em.

Log in as root and run the following:

du  /var/qmail/mailnames | grep 'Maildir/new' | sort -rnk1 > mboxsize.txt

Sample Output:

1047680 /var/qmail/mailnames/
123820  /var/qmail/mailnames/
94156   /var/qmail/mailnames/
88368   /var/qmail/mailnames/

Delete those Suckers

Armed with all the mailboxes that forward and a list of the big offenders you wouldn’t think this would need much explanation, but after several weeks or months of collecting files you may find you have to many files in the directory to delete with a simple “rm * -f”. Apparently there are limits to the number of files you can delete at one time with a wildcard.

If you run into difficulties with rm give this a shot:

CD to the directory and run ‘ls -al’. Note that the name of your server is a string common to all files, replace MYSERVER below with the common string:

find . -name '*MYSERVER*' | xargs rm

In your gusto to clean things out remember that there are legitimate reasons to keep a mailbox turned on for forwarded accounts, (The boss may want to be able to review mail sent to [email protected] to make sure that leads are being followed up on, etc.) and some users may just get incredible amounts of mail. With that in mind this should help you keep a lid on things. Once you’ve got things cleaned out you may be able to use quotas to help the problem from repeating.
Find all posts by this user
Quote this message in a reply
Post Reply 

Forum Jump:

User(s) browsing this thread: 1 Guest(s)