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
It worked perfectly. It took time, it produced prodigious amounts of
output, and there are better ways to do it I'm sure - but it worked
exactly as required.
Of course, if you have an mbox folder then it's a bit more tricky - but
as others have posted already you could convert to Maildir first.
Graeme