I want to parse my /var/log/maillog to print out the email addresses in "from=<>" and "to=<>" (mainly to do a quick check for false positives in the DNS RBLs that I've configured)
A maillog entry looks like this (postfix):
Jun 20 17:27:52 foobarserver postfix/smtpd[15925]: NOQUEUE: reject: RCPT from sbr.nouveauquebec.com[184.22.154.110]: 554 5.7.1 Service unavailable; Sender address [corporate@nouveauquebec.com] blocked using urired.spameatingmonkey.net; Red listed, see http://spameatingmonkey.com/lookup/nouveauquebec.com; from=<something@spam.com> to=<foo@foo.bar> proto=ESMTP helo=<sbr.nouveauquebec.com>
and my regex is
from=<(\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b)> to=<(\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b)>
I'm storing the matches in back references \1 and \2 which I want to print out. What I want to do is pipe the output from cat /var/log/maillog and apply the regex on each line and output the backreferences.
Is there a quick way to accomplish this?
