# Postfix + amavisd-new: queue/message ids not being reused

## c00l.wave

Since our mail server is getting increasingly more spam when just using policyd-weight for rejection, I decided to setup amavisd-new for content filtering (everything set to PASS, just wanting the headers for maildrop to move spam into a separate IMAP). It works so far but if I understood the Postfix readme from amavisd correctly, I should be able to trace mails by their message/queue id.

Unfortunately, my system generates many IDs instead of reusing one of the existing ones:

1. The message itself may contain a message-id (or not...)

2. The message gets queued after it passed policyd-weight checks and entered the original postfix instance, resulting in a local queue id

3. The message gets forwarded to amavisd-new (SMTP or LMTP, doesn't matter); I don't see the "queued_as" debug info on the log, instead it gets some funny mail_id generated by amavisd; however this may be configurable by uncommenting $log_templ

4. After amavisd-new completes, it delivers the mail to another postfix instance for delivery which will result in yet another ID...

It's a mess to trace messages this way on the log. The example output from the readme much cleaner: (from http://www.ijs.si/software/amavisd/README.postfix.html#basics_testing)

```

Nov  1 11:28:10 mail postfix/smtpd[30986]: connect from localhost[127.0.0.1] 

Nov  1 11:28:10 mail postfix/smtpd[30986]: 079474CE44: client=localhost[127.0.0.1]

Nov  1 11:28:10 mail postfix/cleanup[30980]: 079474CE44: message-id=<20061101102810.079474CE44@mail.example.com>

Nov  1 11:28:10 mail postfix/qmgr[20432]: 079474CE44: from=<>, size=822, nrcpt=1 (queue active)

Nov  1 11:28:10 mail amavis[30897]: (30897-02) Passed BAD-HEADER, <> -> <postmaster>, quarantine: badh-le5gjszxowBk, mail_id: le5gjszxowBk, Hits: -1.76, queued_as: 079474CE44, 39505 ms 

Nov  1 11:28:10 mail postfix/smtpd[30986]: disconnect from localhost[127.0.0.1]

Nov  1 11:28:10 mail postfix/local[30987]: 079474CE44: to=<postmaster@example.com>, relay=local, delay=0.27, delays=0.14/0.05/0/0.08, dsn=2.0.0, status=sent (delivered to mailbox: postmaster) 

Nov  1 11:28:10 mail postfix/qmgr[20432]: 079474CE44: removed

```

Is there any parameter I should look for to get the queue or message id reused as in the example? I searched both configs, checked the manuals and FAQs but I still can't find anything about that issue.

The MTA was set up following the Virtual Mailhosting System with Postfix Guide a few years ago, amavisd-new was configured by closely following their readme.

Or am I misunderstanding something? Is it necessary to have independent IDs all over the place? I think it would be more reasonable to keep the IDs for being able to reidentify messages since amavisd is placed "in between" the mail processing but maybe Postfix works different than how I would implement it.  :Wink: 

I tried to set always_add_missing_headers=yes (which is told to break DKIM?) without effect.

What about mailgraph? I feel like it would not check that deep and simply chart 2 or 3 mails for only one mail that has been processed because the queue ids don't match....

----------

## richard.scott

I've use this email scanning setup for years and never figured it out.

I thought it was just the way the system worked.

I'd be interested to find out about message-id's too.

Rich

----------

