and fro the Apple crap "<whatever> (username)" :-) thank you, the script below works perfect
[harry@srv-rhsoft:~]$ cat /www/thelounge.net/contentlounge/updateservice/package/modules/dbmail/cron_cleanup_trash.php <?php /** * @package Content-Lounge-Admin-DBMail * @copyright 2009 - 2013 Reindl Harald <[email protected]> */ /* @var $cl_api api_class */ /* @var $db mysql_class */ $debug = 0; if(PHP_SAPI != 'cli') { exit('CLI-Script'); } require_once(__DIR__ . '/init.inc.php'); $dbmail->log('Trash: Cleanup started'); $trash_folders = array ( 'TRASH', 'DELETED MESSAGES', 'DELETED ITEMS', 'DELETED MAILS', 'REMOVED MESSAGES', 'REMOVED ITEMS', 'REMOVED MAILS', 'PAPIERKORB', 'GEL&APY-SCHTE ELEMENTE', ); $total_size = 0; foreach($trash_folders as $cur_folder) { $result = $dbmail->db->query_fetch_all('select' . SQL_BIG_NO_CACHE . ' id,messagesize,internal_date from `dbmail_physmessage` where id in (select physmessage_id from `dbmail_messages` where mailbox_idnr in (select mailbox_idnr from `dbmail_mailboxes` where `name` like \'' . $dbmail->db->addslashes($cur_folder) . '%\')) and internal_date < date_sub(now(), interval 3 month);'); if(count($result) > 0) { foreach($result as $row) { $total_size += $row['messagesize']; $dbmail->db->query('delete from dbmail_messages where physmessage_id=' . (int)$row['id'], 1, 1); } echo utf8_encode(strtoupper(mb_convert_encoding($cur_folder, 'ISO-8859-1', 'UTF7-IMAP'))) . ': ' . count($result) . MY_LE; } } if($total_size > 0) { echo MY_LE . 'SIZE: ' . GetSizeString('', $total_size) . MY_LE; } $dbmail->log('Trash: Cleanup finished'); ?> Am 10.01.2013 20:20, schrieb Jesse Norell: > Don't forget other "Trash" folder names, like "Deleted Messages", > "Deleted Items" and similar. > > > On Thu, 2013-01-10 at 19:59 +0100, Harald Leithner wrote: >> Hi, >> >> a simple version could be: >> SELECT * FROM `dbmail_physmessage` p WHERE id IN (SELECT physmessage_id >> FROM `dbmail_messages` m >> WHERE mailbox_idnr >> IN ( >> SELECT mailbox_idnr >> FROM `dbmail_mailboxes` ma >> WHERE `name` LIKE 'TRASH' >> ) >> ) >> and >> internal_date < date_sub(NOW(), interval 1 year); >> >> >> It uses internal_date of the physmessage I think thats the date the mail >> arrives at dbmail. >> >> Deleting should be done per update the message table deleted_flag column >> and the temp table. >> >> And then wait for the dbmail_util cronjob. >> >> regards >> >> Harald >> >> PS: its only a quick shoot and could be completly wrong.... >> >> Am 10.01.2013, 18:57 Uhr, schrieb Reindl Harald <[email protected]>: >> >>> hi >>> >>> has someone a queray in the background who finds all >>> messages of any user in folders called "Trash" which >>> are older than 365 days? >>> >>> many users do not recognize that "delete" on IMAP >>> is not really delete and i would like to get free >>> the wasted space to reduze storage size / backup-times >>> and prevent inndob files growing more an more at all
signature.asc
Description: OpenPGP digital signature
_______________________________________________ DBmail mailing list [email protected] http://mailman.fastxs.nl/cgi-bin/mailman/listinfo/dbmail
