This program will only grab the most recent (last) Received: line's IP
address.
It can be modified to do more if you like, or you could just have it dump
its output to a file listing IPs and every night run it through sort & uniq.
-x-CUT-x
#!/usr/bin/perl
$names="name1|name2|name3";
while (<>)
{
if (/Received: from/) { $received = $_; }
if (/To:.*$names/i)
{
$received =~ s/(([0-9]{1,3}\.){3}[0-9]{1,3})/$1/;
$SpamIP = $1;
# If you want to print them out ...
print "$SpamIP\n";
}
}
-x-CUT-x
> i would like to process them automatically via a .qmail* file, and one
> thing i would like to extract automatically is the IP of the SMTP relay
> that sent the mail to our server. example:
> [...]
> so i would like to extract 194.206.111.65 from the line
> Received: from unknown (HELO srvweb.IMPI-GIPSI.FR) (194.206.111.65)