Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: exim: users

Reinject Email

 

 

exim users RSS feed   Index | Next | Previous | View Threaded


exim at csstn

Feb 4, 2010, 8:37 PM

Post #1 of 5 (1157 views)
Permalink
Reinject Email

I need to be able to reinject email from the /var/spool/mail/{user} file
back into exim for delivery to the original recipient. Last week I had to
put my server in place as a backup for another client while their hardware
was repaired. Now that their email server is running again, they want me to
take the contents of their mail file on my server, and send it to their
server.



I know I could forward the messages, but then the "FROM" and original date
and time will be lost.



I do not have the option of moving the email file to the new server, as the
formats are different.



Does anyone have a suggestion how I can accomplish this?



Thanks in advance

Terry





--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


hs at schlittermann

Feb 4, 2010, 10:54 PM

Post #2 of 5 (1099 views)
Permalink
Re: Reinject Email [In reply to]

Exim <exim [at] csstn> (Fr 05 Feb 2010 05:37:02 CET):
> I need to be able to reinject email from the /var/spool/mail/{user} file
> back into exim for delivery to the original recipient. Last week I had to
> put my server in place as a backup for another client while their hardware
> was repaired. Now that their email server is running again, they want me to
> take the contents of their mail file on my server, and send it to their
> server.
>
> I know I could forward the messages, but then the "FROM" and original date
> and time will be lost.

Depending on the number of account you can use mutt and it's „bounce“
function:

as user:
mutt

as root:
mutt -f /var/spool/mail/$USER

… then tag all messages T.*<ENTER>
… then bounce all messages ;b<NEW ADDRESS><ENTER>


Or have a look for „formail“, this can execute any command on the mails
of an mbox, so you could resend them using exim directly. The envelope
sender will change probably, but this should not be a problem. The
delivery date will change too, but this you can't avoid. The Date-Header
should remain.

exim <NEW ADDRESS> < message


Best regards from Dresden/Germany
Viele Grüße aus Dresden
Heiko Schlittermann
--
SCHLITTERMANN.de ---------------------------- internet & unix support -
Heiko Schlittermann HS12-RIPE -----------------------------------------
gnupg encrypted messages are welcome - key ID: 48D0359B ---------------
gnupg fingerprint: 3061 CFBF 2D88 F034 E8D2 7E92 EE4E AC98 48D0 359B -
Attachments: signature.asc (0.19 KB)


km at krot

Feb 5, 2010, 12:34 AM

Post #3 of 5 (1100 views)
Permalink
Re: Reinject Email [In reply to]

* Exim [2010-02-04 22:37]:
> I need to be able to reinject email from the /var/spool/mail/{user} file
> back into exim for delivery to the original recipient. Last week I had
> to put my server in place as a backup for another client while their
> hardware was repaired. Now that their email server is running again,
> they want me to take the contents of their mail file on my server, and
> send it to their server.
>
> I know I could forward the messages, but then the "FROM" and original
> date and time will be lost.

You could just re-send the mail. I.e. you take one message from
/var/spool/mail/{user}, extract *envelope* sender and re-send it using
e.g. exim -f '<sender address>' '<recipient>' for each message.

> I do not have the option of moving the email file to the new server, as
> the formats are different.

What is the format on your side and what is the format on remote side? I
assume mails are stored in mbox format on your server.

> Does anyone have a suggestion how I can accomplish this?

There is more than one way to do it. The best is probably just convert
from one format to another and then transfer to the other server.

Here's some tools that should convert mbox to maildir:

http://untroubled.org/mbox2maildir
http://batleth.sapienti-sat.org/projects/mb2md/

-- Kirill

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


graeme at graemef

Feb 5, 2010, 1:31 AM

Post #4 of 5 (1091 views)
Permalink
Re: Reinject Email [In reply to]

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 [at] _OUR_DOMAIN>"
sleep 0.2
echo "RCPT TO:<$user [at] _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


--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/


km at krot

Feb 5, 2010, 6:32 AM

Post #5 of 5 (1080 views)
Permalink
Re: Reinject Email [In reply to]

* 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 [at] _OUR_DOMAIN>"
> sleep 0.2
> echo "RCPT TO:<$user [at] _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

--
## List details at http://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/

exim users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.