Sebastian Mogilowskis Blog

Just another blog about administration, linux and other stuff

Language: German English

Postfix with Spamassassin filter your mails

This article describes how to filter spammails with spamassassin and deliver them into a own postbox. A script delete the mails in this box after 7 days.

I’m using a Postfix Mailserver on Debian Etch with amavis and spamassasin.

Fist we want to catch only realy hard spam. Normaly no real mail get an Spamscore over 7 points. Change the required hits in the spamassasin configuration.

vim /etc/spamassassin/local.cf
required_hits 7.0

After that configurate the redirection in the postfix configuration:

vim /etc/postfix/main.cf
# Spam Forward
header_checks = regexp:/etc/postfix/header_checks
vim /etc/postfix/header_checks
/^X-Spam-Flag: YES/ REDIRECT spam@yourdomain.com
/etc/init.d/postfix reload

Now all Mails with the Spam-Flag=Yes will be delivered to the spam@yourdomain.com account on your mailserver. If you miss any important mail, you can check this account.

Now create a script which delete this mails after 7 days.

vim /usr/local/bin/deleteOldSpam.sh
#!/bin/bash
find /path/to/your/mailhome/cur -type f -mtime +7 -exec rm {} \;

After that create an cronjob for this script:

crontab -e
0  1 * * * /usr/local/bin/deleteOldSpam.sh # Delete old Spammails

Now every day at 01:00 all spammails older than 7 days will be deleted.

Don’t forget to modify /path/to/your/mailhome/cur to the path where you store the mails of your spam account user.

, , , ,

One Response to “Postfix with Spamassassin filter your mails”

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

eMail-Benachrichtigung bei weiteren Kommentaren.
Auch möglich: Abo ohne Kommentar.