Third-Party Software

rblcheck works well as a command-line tool for performing lookups, but it also serves an important role working with other software, such as mail servers and email filtering programs.

Procmail

rblcheck was really designed to be used with procmail, as long as you have access to the IP address of the system sending you email. Surprisingly, most MTAs make obtaining this information more difficult than it needs to be. The procmail rule I present here assumes you've found some way to put the IP address of the sender in the variable TCPREMOTEIP. See the sections below on Sendmail and QMail for ideas on how you can get ahold of this value.

The following procmail rule will, once you have TCPREMOTEIP, use rblcheck to look up the IP address in the built-in filters:

:0
* ! ? if [ -n "$TCPREMOTEIP" ]; then rblcheck -q "$TCPREMOTEIP"; fi
{
	EXITCODE=100
	LOGABSTRACT=all
	LOG="Filter: RBL-filtered address: \"$TCPREMOTEIP\"
"
	:0:
	$FILTER_FOLDER
}

FILTERFOLDER is assumed to have been set up ahead of time as the place to put email that you don't want to see (either another incoming folder, /dev/null, or a 'formail' invokation that rewrites the message and tacks on an extra header or munges the subject so you can easily identify it.

Note that EXITCODE above is for QMail, and indicates a permanent error. Under Sendmail, 77 is more appropriate. Under anything else, it's hard to say; your best bet is to refer to the documentation regarding execution of programs.

One more thing: procmail has a nasty habit of munging the environment, but most MTAs already do this for you. Hence, you should add the '-p' flag to the invokation of procmail (either from a local delivery rule in Sendmail, or from a .forward or .qmail file). This will ensure that procmail doesn't clean out the value of TCPREMOTEIP.

To test the procmail recipe:

  1. Save any mail message, with full headers, to a file.

  2. Run procmail with the environment variable TCPREMOTEIP set to an offending address, and with the message you just saved as input:

    cat message | env - TCPREMOTEIP=127.0.0.2 procmail -p

  3. Check your procmail log and mailbox. If the message went through, you have a problem. If you have a message in your logfile stating that the message was bounced for being in the RBL, you're fine.

  4. Run procmail with the environment variable TCPREMOTEIP set to a non-filtered address, such as 127.0.0.1, and with the message as input:

    cat message | env - TCPREMOTEIP=127.0.0.1 procmail -p

  5. Check your procmail log and mailbox. If the message didn't go through, you have a problem. If you have a copy of the message in your mailbox, and no errors in your log file, you're fine.