Friday, July 31, 2009

Sunday, July 19, 2009

How to prevent auto-replies to be sent when spams are received

This is a simple solution to not send auto-reply messages when you receive a spam, using spam assaassin, postif and webmin auto-reply system.

Here, I consider that you use webmin to manage your server and auto-replies , that your mail server software is postfix and spamassassin is configured and works. Since the default way spamassassin works is to add some text to the subject of your emails if it is detected as a spam, I consider that the text which is added is "[SPAM]".

To prevent the autoreply system set by Webmin to send a reply to emails detected as spam, just add the following code in file /etc/webmin/postfix/autoreply.pl at line 77:
if ($header{'subject'} =~ m/[SPAM]/) { exit 0; }
If your spamassasin system add another string to the subject, change [SPAM] for a string corresponding to your system.

Once everything seems to work perfectly, you have to modify the file autoreply.pl stored in the library folder of webmin, since webmin will replace the thew one you already modified by the one in its library folder every time an autoreply is created/modified. To do that, just copy the one you modified over the one in webmin library folder:
cp /etc/webmin/postfix/autoreply.pl /usr/libexec/webmin/postfix/autoreply.pl



That's it that's all...