Re: [exim] Reinject Email

Top Page
Delete this message
Reply to this message
Author: Kirill Miazine
Date:  
To: Graeme Fowler, exim-users
Subject: Re: [exim] Reinject Email
* Graeme Fowler [2010-02-05 09:31]:
> On Thu, 2010-02-04 at 22:37 -0600, Exim wrote:
> > Does anyone have a suggestion how I can accomplish this?
>
> I recently had to do this very thing with a broken Exchange server,
> having to "replay" several days worth of messages from a large number of
> backup Maildir INBOX folders to a rebuilt Exchange database.
>
> Firstly I generated a list of usernames from the email addresses I was
> given, and then did this:
>
> #!/bin/sh
>
> for user in `cat list_to_replay.txt`
> do
> echo $user
>
> dir=`grep ^$user: /etc/passwd | cut -d: -f6`
>
>   if [ -d $dir/Incoming-Mail-Backup/new ]
>   then
>     cd $dir/Incoming-Mail-Backup/new
>     # select messages from 00:00 on Sat 16th thru 15:50 Mon 18th
>     for msg in 1263[67]* 12638[012]*
>     do
>       (
>         sleep 1;
>         echo "EHLO _MY_MACHINE_NAME_"
>         sleep 0.2
>         echo "MAIL FROM:<$user@_OUR_DOMAIN_>"
>         sleep 0.2
>         echo "RCPT TO:<$user@_OUR_DOMAIN_>"
>         sleep 0.2
>         echo "DATA"
>         sleep 0.2
>         cat $msg
>         echo "."
>         sleep 1
>         echo "QUIT"
>       ) | nc -w 60 _TARGET_HOST_ 25
>     done
>   else
>     echo "$dir/Incoming-Mail-Backup/new not found"
>   fi
> done


Quick, easy and nice. There's a bug here: if a message contains a dot on
a line by itself, the message will be submitted right away. Also it'd be
better to move sent messages off to another directory, in case you need
to stop the script and start it again later.

-- Kirill