Thanks for all the insightful answers. So, I actually use the long_queue_ids options and I save the queue_ids to a database to later compare them to the queue_ids found in the mail log to parse and mark the bounces. The problem - and thus the source for my question - is that this always means a string compare in the database search which is aweful for performance. So my thought was, to always pass a unique Message-ID to postfix equal to the autoincrement ID in my database, and then set this Message-ID as the mail's queue_id. This way the lookup in the database would be much faster plus I wouldn't have to save the queue_id in the database in the first place (huge performance boost). In my case I can guarantee that the Message-ID is always passed and that it is unique, so that wouldn't be the problem. But if Postfix creates the queue file name before receiving the message content then it actually is a bigger problem than I thought, except if I could change the queue_id or append the id to the queue_id...
If that doesn't work though then maybe I could work around this problem. I thought about adding the message-id to the bounce message but that probably won't work because the message-id would not be in Postfix anymore at the time the bounce happens. Any other options that I could try? Really appreciate your help here! Best, Steffen -----Ursprüngliche Nachricht----- Von: owner-postfix-us...@postfix.org [mailto:owner-postfix-us...@postfix.org] Im Auftrag von Wietse Venema Gesendet: Mittwoch, 3. Oktober 2012 18:47 An: Postfix users Betreff: Re: How to change queue id? Steffen Schebesta: > Hello everybody, > > I deliver mails to my Postfix through smtpd. Postfix then takes it and > sends it out to the recipient. > > Now I'm trying to change the queue_id for each email in Postfix 2.9 > source code so that it is equal to the Message-ID (it is unique, don't > worry) that I set in the email header when passing the email to Postfix through smtpd. > I've looked in the source code for hours but cannot find the first > time queue_id is set. > > In smtpd.c that (in my understanding) handles incoming mail through > smtpd the variable state->queue_id is already used and only read but not written. > > I would really appreciate any tips where I can find the initial > setting and on how I can set state->queue_id to Message-ID Reasons not to use the message-id as the queue file name: - Different messages may contain the same Message-ID value. - Some messages don't contain a Message-ID. This field is not required by current RFC documents. - Chicken-and-egg problem: Postfix chooses the queue file name (and creates the file) before it receives the message content. I suggest that you set "enable_long_queue_ids = yes". Long queue ID strings don't repeat as long as your clock moves forward. Wietse