OT reassemble df qf pair

Jim Holland mailscanner at mango.zw
Mon Oct 9 14:21:15 IST 2006


On Sun, 8 Oct 2006, Mark Nienberg wrote:

> Date: Sun, 08 Oct 2006 19:54:37 -0700
> From: Mark Nienberg <gmane at tippingmar.com>
> Reply-To: MailScanner discussion <mailscanner at lists.mailscanner.info>
> To: mailscanner at lists.mailscanner.info
> Subject: Re: OT reassemble df qf pair
> 
> René Berber wrote:
> > Mark Nienberg wrote:
> > 
> >> Every once in a while, in order to troubleshoot a particular delivery
> >> problem, it would be nice if I could reassemble a sendmail (qf df) pair
> >> into the original message.  If someone could tell me how to do that, I
> >> would greatly appreciate it.
> > 
> > In MailScanner's bin directory there is a utility called df2mbox, it may be what you are looking for.
> 
> I don't think that is quite the ticket.  The resulting headers are 
> incomplete, not the same as the original message.
> Thanks for the suggestion though.

I append a quick mod to Julian's script that seems to do what you want but
for a single queue file pair.  It recreates the original headers correctly
as far as I can see.  The major change is the addition of a match for 
header lines that start with a space as well as those that start with a 
tab.

Regards

Jim Holland
System Administrator
MANGO - Zimbabwe's non-profit e-mail service

#!/bin/bash
# q2msg
# Converts sendmail df and qf queue file pair to RFC 822 msg format

# Run this as:
#   q2msg [[dfile] | [qfile]]
# Output is $qid.msg

infile=$1
qid=`echo $infile | sed 's/^[qd]f//'`
outfile=$qid.msg
from=`grep '^S' qf$qid | sed 's/^S//' | tr -d '<>'`

(   echo "From $from  `date -R`"
    # Note that the long gap in the next line is a tab character!
    egrep '(^H\?[^\?]*\?)|(^    )|(^ )' qf$qid | sed 's/^H?[^?]*?//' \
      | grep -v "Return-Path: <.g>"
    egrep '^R[A-Z]*:' qf$qid | sed 's/^R[A-Z]*:/X-MailScanner-Recipient: /' \
      | tr -d '<>'
    echo
    cat df$qid
    echo
) > $outfile




More information about the MailScanner mailing list