Procmail/Formail recipe question
I've got a fromail recipe embeded in my .procmailrc that I use to determine the following information:
X-SenderIP:
X-ASN:
X-CIDR:
This works fine for my main isp, Earthlink. but, I want it to also work for my own domain, toadnet.com and for mail I pickup from yahoo using fetchyahoo. All mail is being filtered through procmail, I just can't get the above information added to toadnet and yahoo at the end of the headers. Below is the recipe:
# Add X-ASN header
# KMSelf Sun Jul 11 04:05:32 PDT 2004
#
# Add headers for ASN and originating IP.
# Original author: Karsten M. Self
#
# Requires FORMAIL variable be set (most procmail recipe sets do this).
#
# You *must* set your SMTP_SERVER identifier.
#
# Run this *BEFORE* any spamassassin processing. The header tag itself
# should start being scored as a Bayesian attributed.
# FORMAIL = /usr/bin/formail
SMTP_SERVER = (EarthLink SMTP Server|by toadnet\.com (\8\.12\.11/8\.12\.11\)|by mta[0-9]*\.mail\..*\.yahoo\.com)
# ----------------------------------------------------------------------
# Parse out the sender's IP address.
SENDERIP = `formail -c -XReceived | grep "$SMTP_SERVER" | \
tr '[][\t <>()]' '\n' | \
grep '^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$' | \
tail -1`
# Reverse IP for reverse DNS query
REVERSE_SENDERIP = `expr "$SENDERIP" | \
sed "s/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\4.\3.\2.\1/"`
# Query asn.routeviews.org for the ASN.
# Note that this is pretty aggressive: wait six seconds, retry ten
# times, may slow mail processing, but tends to improve data quality.
# Run a caching DNS server for improved performance.
# Raw is a mostly unmunged output (save quotes and prefix). Contains
# ASN, IP, and CIDR prefix.
RAW_ASN = `host -W 6 -R 10 -t txt $REVERSE_SENDERIP.asn.routeviews.org | \
sed -e 's/.* text //' -e 's/"//g'`
ASN = `echo $RAW_ASN | cut -d ' ' -f 1`
ASN_CIDR = `echo $RAW_ASN | cut -d ' ' -f 2`/`echo $RAW_ASN | cut -d ' ' -f 3`
# LOG = "SENDERIP= $SENDERIP"
# LOG = "REVERSE_SENDERIP= $REVERSE_SENDERIP"
LOG = "ASN= $ASN"
# ------------------------------------------------------------------------
# Add X-SenderIP header.
:0 fhw
* ! ^X-SenderIP:
| $FORMAIL -a "X-SenderIP: $SENDERIP"
# ------------------------------------------------------------------------
# ------------------------------------------------------------------------
# Add X-ASN header.
:0 fhw
* ! ^X-ASN:
| $FORMAIL -a "X-ASN: ASN-$ASN"
# ------------------------------------------------------------------------
# ------------------------------------------------------------------------
# Add X-CIDR header.
:0 fhw
* ! ^X-CIDR:
| $FORMAIL -a "X-CIDR: $ASN_CIDR"
# ------------------------------------------------------------------------
It originally started off as the smtp_server line being only earthlinks, the others have been added since. The output is supposed to look like:
X-SenderIP: 65.54.169.39
X-ASN: ASN-8075
X-CIDR: 65.54.160.0/19
Which it does for mail from earthlink, however, from toadnet and yahoo it looks like this:
X-SenderIP:
X-ASN: ASN-
X-CIDR: /
I'm pretty sure the problem is in this line:
SMTP_SERVER = (EarthLink SMTP Server|by toadnet\.com (\8\.12\.11/8\.12\.11\)|by mta[0-9]*\.mail\..*\.yahoo\.com)
However, I can't seem to find it. Any assistance would be appreciated
Chris
|