Hi. I got a little problem in my office. I use SquirrelMail webmail client to provied IMAP access to the email accounts on my office. We limited the account to 10 MB. The problem is that they don't purge the Trash Folder, no matter what I tell them.
So, I workout the problem writing a simple shell script that uses mysql client to generate a list of all the messages that are in Trash folders and where deleted_flag isn't set. Later, uses a little for loop to set those messages properties to delete status: deleted_flag='1' status='002' You only have to use the dbmail-maintenance -d and dbmail-maintenance -p to take those messages out of the database. I use a loop instead of a single SQL command to write to stdout a list of the messages I deleted, so I can create a small log for administrative issues. Here is the script, just edit MYSQL prefixed variables to your settings: # /bin/sh # # Set deleted flag in any email in Trash Folder # MYSQL=/opt/mysql/bin/mysql MYSQLHOST=localhost MYSQLUSER=username MYSQLPASSWD=secret trashmessages=`$MYSQL -h $MYSQLHOST -u $MYSQLUSER -p$MYSQLPASSWD -s -e "SELECT messages.message_idnr FROM dbmail.users, dbmail.mailboxes, dbmail.messages WHERE users.user_idnr=mailboxes.owner_idnr AND mailboxes.mailbox_idnr=messages.mailbox_idnr AND mailboxes.name='Trash' AND messages.deleted_flag='0' AND messages.status='000' ORDER BY messages.status"` for message in $trashmessages do echo "Deleting message $message from Trash folders... \c" $MYSQL -h $MYSQLHOST -u $MYSQLUSER -p$MYSQLPASSWD -s -e "UPDATE dbmail.messages SET deleted_flag='1', status='002' WHERE message_idnr='$message'" echo "done" done