Forwarding email from one host to a new after migration


It seems a lot of people will move to a new server and want all the old email stuck in /var/mail – its not as easy as it seems to get the email migrated according to google, so I thought i would document it.

If you have IMAP available, simply add the new account and drag and drop between the 2 accounts. Some mail clients do not support this, however thunderbird does and its free, so go ahead and use that. If you are doing it via IMAP there are also a few imap sync scripts around, some done in perl, some in bash etc.

If you had your host accepting mail for a domain that hosted its email elsewhere on the net, and that web server does not host email but you ended up with a pile of data in /var/mail then try this.

Make sure procmail is installed, this is where the program formail comes from.

 cat /var/mail/mbox | formail -s sendmail -oem emailaddress@hostname.com