Resending mail with Exim4
Today’s challenge is to take all the email in a mailbox and send it on to a new address. I need to do this because of a friend I had been hosting email for on my home box. He now has a new email address and I want to forward all the mail in his account to his new address before shutting down the old account.
I am running Debian Etch and using exim4 which is the default mailer for Etch. Fortunately for me, exim4 stores each mail in a separate file in the directory ~/Maildir/cur. The files are already in MIME format so all I need to do is pipe them back to exim with a new address.
Here are the magic commands to do it. In this example, I am sending all messages for user “bobp” to the new address “bob@boogermail.com”. You will obviously need to replace these with more relevant names.
cd /home/bobp/Maildir/cur for file in `ls`; do exim4 bob@boogermail.com < $file; done
Don’t forget the back-ticks on the ls command!
