How about something like this
Code:
#!/usr/local/bin/php
<?
// read from stdin (could be a filter)
// Get the IP address from the folloowing line
//2004-09-10 05:13:40 H=(dsl-201-135-79-196.prod-infinitum.com.mx) [201.135.79.19
6] F=<mrebfuzbtrf@excite.it> rejected RCPT <nabe@mydomai.com>: you have sent e-ma
il to a spam trap. your e-mail has been discarded.
$fd = fopen("php://stdin", "r");
$email = "";
while (!feof($fd)) {
$email .= fread($fd, 1024);
}
fclose($fd);
$SUB = strstr($email, "RCPT"); // find the line we need
$S = explode("]",$email); // get everything before the ]
$IP = explode("[",$S[0]); // get everything before after the [
echo $IP[1]; // echo just the IP addres
?>