DBMail Auto Deletion

The following SQL statement will mark messages older than 180 days as candidate for deletion (a job later taken on by dbmail-util -ay).

UPDATE dbmail_messages SET status = 2 WHERE physmessage_id NOT IN
     (SELECT physmessage_id FROM dbmail_datefield WHERE date_sub(curdate(), interval 180 day) < = datefield);

At this time, this appears to be compatible with the archiving strategy I've developed. The idea is to maintain 6 months of “online” mail since older messages will exist in the archive anyway.


Right now, the code above is mailbox-agnostic and will therefore, delete *all* mail in the database that is older than the defined number of days. At the moment, I'm still not sure I'll be using this strategy at all so I haven't decided how flexible I need to make it.

dbmail_auto_delete.txt · Last modified: 2012/02/27 21:52 by bas
DBMail is developed by Paul J Stevens together with developers world-wide