LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 12-31-2005, 11:41 PM   #1
Toadman
Member
 
Registered: Aug 2002
Location: Texas
Distribution: Ubuntu 14.04 LTS
Posts: 171

Rep: Reputation: 15
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
formail fails on virtual user [qmail,vpopmail,procmail,formail] jonavogt Linux - Networking 2 01-15-2009 10:29 AM
formail with procmail priyesh Programming 2 10-23-2003 12:01 AM
Procmail and formail aBl_tR3kr Linux - Software 1 03-26-2003 11:15 AM
procmail and formail aBl_tR3kr Linux - Networking 1 03-26-2003 11:02 AM
procmail and formail aBl_tR3kr Linux - Newbie 0 03-26-2003 10:41 AM


All times are GMT -5. The time now is 08:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration