February 28, 2010

maildrop whitelists and blacklists

Sysadmin | Comments (0) admin @ 7:50 am

SpamAssassin and greylisting are great tools for reducing the amount of spam thats cluttering our mailboxes, however theres always those false positives that in a business environment can become quite critical.
One of the ways to improve the delivery of important emails is to create whitelists, respectively blacklists, to make sure we are not missing anything vital.
Maildrop has some very nice filtering capabilities, but as with any complex software its easy to make mistakes.
It took me some time to play around, trying to create a whitelist, till I found the lookup function which seems the perfect fit for this.
Heres my new mailfilter config which now has a white/black - list.

SHELL=/bin/sh
SPAM="/path/to/spam/Maildir/"
MAILBOX="/path/to/user/Maildir/"

/^From:.*/
getaddr($MATCH) =~ /^.*/;
MATCH=tolower($MATCH)

if ( lookup($MATCH, "geek.ro-blacklist") )
         to "$SPAM"
if( lookup($MATCH, "geek.ro-whitelist") )
         to "$MAILBOX"
if (/^X-Spam-Status:  *Yes*/)
         to "$SPAM"
to "$MAILBOX"

the geek.ro-whitelist, geek.ro-blacklist files are just regexes to match against the sender’ email address, (e.g. .*@domain\.com), one per line.

May 26, 2009

Amavis - MySQL server has gone away

Sysadmin | Comments (0) admin @ 8:01 am

I found this error cluttering my system logs:
May 26 06:39:16 zeus amavis[10981]: (10981-04) NOTICE: reconnecting in response to: err=2006, HY000, DBD::mysql::st execute failed: MySQL server has gone away at (eval 86) line 166, GEN54 line 5.

After a bit of debugging it turns out amavis keeps an open connection to mysql and depending on your wait_timeout setting it might lose the connection and need to reconnect.
In order to fix this you just need to increase your wait_timeout to a comfortable value.

mysql set global wait_timeout=28800;
Query OK, 0 rows affected (0.00 sec)

You also need to edit your my.cnf file to make sure the change is persistent across mysql restarts.