On 7/13/2018 12:39 PM, rog7...@web.de wrote: > Hello, > > I'm looking for a search tool to analyze Postfix logfiles. It should > be something like a multiline grep application which is able to show > all lines, which are related to one incoming mail. Mainly I want to > search for the sender and the recipient at the same time. E.g. > something like that: > > mailgrep "from=<local1@domain1>.*to=<local2@domain2>" /var/log/mail.log > > I assume, that I'm not the first Postfix user with this requirement. > But I couldn't find a suitable tool. Does somebody know an adequate > application or do I have to write it for my own? > > Ingo
Look at the collate.pl tool included with postfix source in the ./auxiliary directory. Alternatives for next time: Using the the header_checks INFO action will log the matching header along with sender and recipient, making an easy grep target. (Single-recipient mail only. Multi-recipient mail will log the sender and the last recipient.) http://www.postfix.org/header_checks.5.html It should be pretty easy to convince the postfwd policy service to log a line for each sender/recipient/QUEUEID. http://www.postfix.org/SMTPD_POLICY_README.html http://www.postfwd.org/ -- Noel Jones