Re: [exim] Dump message to stdout

Startseite
Nachricht löschen
Nachricht beantworten
Autor: Michael Sprague
Datum:  
To: exim-users
Betreff: Re: [exim] Dump message to stdout
On Thu, Aug 16, 2007 at 05:45:19AM -0700, Christian Gregoire wrote:
> Hello,
>
> Is there a way, with the Exim command line, to dump a message (header + body) to stdout, given its message ID ? I would use something like:
> exim -Mvh <ID> > outfile
> exim -Mvb <ID> >> outfile
> but the header file would have first to be parsed to remove all the 'admin' lines and flags, which is not very handy.


Are you refering to messages in the queue? If so, the attached script
does just that. It'll spit out the body section, header section or the
message section based on the args you give it. Just change the "spool"
variable to match your spool and it should work; assuming you're using
the split spool.

thanks,
mikeS

P.S. I am not the original author of the script but I use it all the
time. :)

-- 
Michael F. Sprague     | mfs@???
http://www.saneinc.net | System and Network Engineering (SaNE), Inc
Providers of the SpamOnion anti-spam service

#!/bin/sh

PATH="/usr/bin:/bin"

if [ "$2" = "" ]; then
echo "$0: Usage: emore <b|h|m> <message-id>" >&2
exit 1
fi

spool="/var/spool/exim4"

if `expr $2 : '[0-9a-zA-Z]\{6\}-[0-9a-zA-Z]\{6\}-[0-9a-zA-Z]\{2\}' \
              > /dev/null`; then
  letter="`echo $2| cut -c 6`"
  if [ ! -f "$spool/input/$letter/$2-D" ]; then
    echo "$0: Message does not exist: $2 $spool/input/$letter/$2-D" >&2
    exit 2
  fi


  case $1 in
    b)
      ${PAGER-more} $spool/input/$letter/$2-D
    ;;
    h)
      ${PAGER-more} $spool/input/$letter/$2-H
    ;;
    m)
      ${PAGER-more} $spool/msglog/$letter/$2
    ;;
    *)
      echo "$0: Usage: emore <b|h|m> <message-id>" >&2
      exit 1
    ;;
  esac
else
  echo "$0: Invalid message id: $2" >&2
  exit 3
fi


exit 0