Mailscanner changes mail unique ID

Glenn Steen glenn.steen at
Thu Dec 10 14:29:34 GMT 2009

2009/12/10 Glenn Steen <glenn.steen at>:
> 2009/12/9 Frank Cusack <fcusack at>:
>> On December 9, 2009 12:02:44 PM +0000 Stef Morrell <stef at> wrote:
>>> Postfix uses inode numbers for the queue ID. This means that when
>>> Mailscanner has processed the email and needs to copy it back into the
>>> queue for sending a new inode will be used and that will become the new
>>> queue ID.
>>> So, regretfully, the short answer is no, it's not possible.
>> Mailscanner could copy the file, edit the original in-place and then
>> move the original to the incoming queue.  It's possible, but MS doesn't
>> work that way.
>> -frank
> One might think that yes, but due to how Postfix works (and the
> "unstandard" practices of MailScanner:-), that isn't possible either.
> Apart from making "grep" more easy, there is really no real issue with
> the requeue -> new queue file -> new queue file ID...
> If you're handy with perl, making a "mailloggrep" program that
> correctly parses and "greps" all possible queue IDs for the message
> would be rather simple.
> What we ended up doing, which is to construct a completely new message
> queue file, is actually what Wietse (a rather long time ago, when he
> wanted to demonstrate the "folly" of working with batches of queue
> files instead of (like amavisd) through the limiting interfaces at
> hand (SMTP, mainly)) stipulated as the only sane way of doing this
> (along with some other "rules"...). Fun thing was that he was unaware
> of the fact that MS actually already did all that;-).
> If you like, and have the luxury to wait for me to have some spare
> time,  could probably whip a little script up for you relatively easy,
> especially if you'd not mind it being ugly;-).
> Cheers

Here you go... put this in a file (make sure the perl path is OK, as
well as the path to your mail log file), chmod +x  said file, run as
per the Usage... Ugly and perhaps not the most effective, but ...
-------------------------- cut here
#!/usr/bin/perl -w

open(R,"</var/log/mail/info.log") || die "Shit! $?\n";
die "Usage: mailgrep <queue file ID>\n" if($#ARGV ne 0);
$src = "$ARGV[0]";
while ($_=<R>) {
  print if(/$src/);
  if(/Requeue: $ARGV[0]...... to (\w*)/) {
    $src .= "|$1";
# End of Script
-------------------------- cut here

-- Glenn
email: glenn < dot > steen < at > gmail < dot > com
work: glenn < dot > steen < at > ap1 < dot > se

More information about the MailScanner mailing list