1

Topic: [SOLVED] Automatic cleanup of quarantine

==== Provide basic information to help troubleshoot ====
- iRedMail version: 0.7.3 mySQL
- Linux/BSD distribution name and version: CentOS 5.6
- Any related log? Log is helpful for troubleshooting.
====
Looked all through the forum and couldn't find an answer: thought it would be a common question.

What's the best way to perform an automatic cleanup of the spam quarantine?  Currently I have tweaked amavsid to move spam above a certain level into the quarantine, and it's been 100% flawless in my use with no false positives.  I'd like to have the spam automatically removed from the quarantine after 14 days.  I looked at the cron jobs and didn't see one that was going to do this: is it something I need to add myself?  And if so, what would be the syntax?

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: [SOLVED] Automatic cleanup of quarantine

Also I should note that I'm using iRedAdmin-PRO MySQL 1.3.0.  I found in another post that the action I'm looking for is built in, but is on a 30 day limit.  Is this correct?  I'm concerned that will be way too long... I suspect I'll have hundreds of thousands of messages in quarantine in that time.

3

Re: [SOLVED] Automatic cleanup of quarantine

OK, looked further into it and I see there's a setting in /var/www/iRedAdmin-Pro-MySQL-1.3.0/libs/settings.py:

AMAVISD_REMOVE_QUARANTINED_IN_DAYS = 7

So, I assume this answers my question (apparently I must have changed it from 30 to 7 days as part of the setup).  Does this mean I do need to log into iRedAdmin to trigger this action?

4

Re: [SOLVED] Automatic cleanup of quarantine

iRedAdmin-Pro setting will be triggered when you logging to iRedAdmin-Pro and access "System -> Quarantined Mails".

If you're sure all quarantined mails are SPAM, it's recommended to discard them immediately. Steps:

- Comment out Amavisd setting "@storage_sql_dsn", "$spam_quarantine_to", "$spam_quarantine_method".
- Disable Amavisd integration in iRedAdmin-Pro.

If you want to store them in MySQL, but delete old mails automatically, try executing MySQL commands in cron job.
Below are commands you need:

// First one, used to delete quarantined mails which older than 7 days.
// Change "7 DAY" to whatever you want, e.g. 10, means delete mails older than 10 days.

DELETE FROM msgs WHERE content IN ('S', 's', 'V', 'Y') AND quar_type = 'Q' AND time_num < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 7 DAY))

// Delete old data in table msgs and msgrcpt.

DELETE msgrcpt.* FROM msgrcpt INNER JOIN msgs ON msgrcpt.mail_id=msgs.mail_id WHERE msgs.content IN ('U', 'M', 'H', 'O', 'C') AND msgs.time_num < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 7 DAY))

Note, please make sure you have a new SQL index created:

# mysql -uroot -p
mysql> USE amavisd;
mysql> mysql> ALTER TABLE msgs ADD INDEX msgs_idx_content (`content`);

5

Re: [SOLVED] Automatic cleanup of quarantine

Perfect, this answers my questions.   So far, the whole iRedMail system's been working very well for us... thanks for your hard work on this!