On 10/28/2016 3:49 PM, D'Arcy Cain wrote: > I have a Postfix server that has to receive messages with special X- > headers that I use to update a database before sending the message > on. I store the message ID, current timestamp and details taken from > the X- headers for later processing. Later I scan the logs so that > I can update the database with disposal information such as sent, > bounced or expired. > > To do this I created a content filter that I put into master.conf. > This filter does the above processing and then re-injects the > message back into Postfix as described in the Postfix > documentation. Everything works pretty well. The one issue I have > is that scanning the logs shows two Postfix IDs for each message ID, > once for the original queue and once for the re-injection. I only > care about the second one and I suppose that I can just ignore the > first but that seems kludgy since they could theoretically show up > in different logs. > > Ideally I want my filter to run on the message without removing it > from the queue. That way every message has one and only one Postfix > ID. I can deal with the fact that IDs can be reused but I can > handle that because as far as I can tell they won't be reused during > the time that the message is in the queue. By the time that it is > reused the message will be sent, bounced or expired and I won't be > processing it any more. I am not treating the Postfix ID as a unique > key, only the message ID. > > So, my question, which I am afraid I already know the answer to, is > can I examine the content of each message without interfering with > the regular processing of the message. I know that I can set up two > Postfix servers but that just seems even more kludgy than what I have. > > Thanks for any ideas. >
Enable long queue ids to reduce the likelihood of a postfix queue id repeating. http://www.postfix.org/postconf.5.html#enable_long_queue_ids It is not possible to reliably examine a message with an external process while it's in the postfix queue. Such processing is unsupported and strongly not recommended. Option 1) You might be able to use one of the perl or python based milters to do your filtering. That happens during the receive, and should work just fine. Option 2) A dual postfix instance with a filter between is actually a cleaner implementation than the kludge of doing it all in one mailer. See the MULTI_INSTANCE_README for details on setting this up. http://www.postfix.org/MULTI_INSTANCE_README.html -- Noel Jones