HI, My users never empty their trash, in some cases the user would have a couple of megs of current mail, but over 300 megs in their trash can. This all adds up of course, so I came up with a query to delete items in any mailbox labeled 'Trash' that is over 30 days old. I figured this is a safe method.
This has not been tested very much, so if it hoses your database, it's not my fault. I have run it on my test system a couple of ways, and also once on my production database, and I had no problem. This just updates the deleted flag, so if it eats up the wrong messages, you can just restore them by changing the deleted flag. Also, this is for a 1.x database, I think it would still work on 2.x, but I didn't consider this at all, so be warned. I'm going to set this up as a cron job to run once a week to solve my problem. Here's the SQL: UPDATE mailboxes LEFT JOIN messages USING ( mailbox_idnr ) SET messages.status = 2 WHERE messages.internal_date < DATE_SUB(CURDATE(), INTERVAL 30 DAY) AND messages.status <= 1 AND mailboxes.name LIKE 'Trash' HTH, -Micah
