Some pseudo code:
open pipe from ps aux, perhaps after grepping for sendmail
while(<PIPE>) {
my ($owner, $pid,
undef, undef, undef, undef, undef, undef, undef, undef, # Throw
+eight values away
$command_withIP) = split(' ', $_, 11);
Do stuff
}
Update: What c suggests is a good path to take,
especially since the ps table is rather transitory. You
won't be sure of having a pid match. If the log doesn't
have the IP address, I'm sure that can be set via
sendmail.cf. You may also want to look into /etc/mail
for some more clues.
Update2: thank you bbfu