Monday 16 March 2009

backscatter with sendmail

One of our mail servers recently got listed in backscatter.org for creating back scatter (Non Deliver Reports (NDR) to people who have been listed as the sender of spam).

I was pretty surprised at this as I had configured sendmail such that it should not produce back scatter.

However on closer investigation it was true we were sending back scatter.

The problem lay in the fact that we relay a few accounts to the users isp accounts. One in particular (Demon) issue a 509 if they reject the email as spam.

This was causing our mail server to send an NDR to the from address of the original email.

To solve this problem I used procmail and formail to rewrite and then forward the email rather than simply allowing sendmail to relay it.

By re writing the 'Return-Path' option it means that the NDR is sent to a local address (which is actually /dev/null) rather than the FROM address.

To do this I simply created an account for the user and then created a .procmailrc in the home directory with the following entry

:0fw
| /usr/bin/formail -i "Return-Path: postmaster@mydomain.co.uk" | /usr/lib/sendmail -f postmaster@mydomain.co.uk yyyyyyyy@myotherdomain.co.uk

postmaster@mydomain.co.uk is simply sent to 'junkmail'
junkmail is an alias (in aliases) for /dev/null

The original Return-Path can be seen in the mail header as Old-Return-Path should you ever need it.

You can verify everything is working by simply checking your maillog (and the fact you have no more NDR mail sat for days in your outgoing queue!)

If you need to monitor your mail server check out www.ippatrol.com