Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to migrate a client's hosting from a really bad host to a new one.

The current host provides no control panel (they're a bit control freaks, you have to lodge a ticket to do anything) so I can't back up the mail from the control panel.

I need a way to grab the mail from the mailboxes and transfer it onto the new host.

As far as I know, they only provide pop3 on their server either so I can't use imapsync.

The new host is a vps with cpanel, I can install whatever could help on it.

Is there any way that I can automate the transfer from the old host to the new one?

Am I doomed?

share|improve this question
    
What kind of mail server do you plan on running on the new host? –  Handyman5 Aug 25 '11 at 1:36
    
@Handyman5 - it's a CentOS with cPanel vps, so I'm guessing exim. –  Ben Aug 25 '11 at 2:02
1  
Most POP clients will download the mail from the server and store it locally within the mail client, so in most cases there wouldn't be any mail stored on the server to migrate. Some clients have an option to keep a copy on the server (sometimes forever, sometimes for X days), but even if the copy on the server goes away the client will generally retain a local copy of the message regardless of what the server does on its end. Usually in a pure-POP environment you can just migrate the accounts and point the client to the new server with no loss of stored mail. –  Justin Scott Aug 25 '11 at 4:09
    
@Justin. Except that some users only access their mail through webmail. –  Ben Aug 25 '11 at 6:10
    
@Ben but that you have webmail was not in your specification... –  mailq Aug 25 '11 at 19:16
show 2 more comments

3 Answers

up vote 4 down vote accepted

If you use a Unix/Linux solution (like Postfix/Dovecot), you could just use fetchmail or something like that to get the mails from the old server and inject it into the local mail system on the new one.

All you would need is a list of usernames/passwords for the POP accounts on the old server.

share|improve this answer
    
@SvenW.. ok, interesting.. can you recommend a good tutorial/example on using fetchmail? –  Ben Aug 25 '11 at 2:04
    
The fetchmail man page is actually quite good and informative and even has config examples: fetchmail.info/fetchmail-man.html#42 –  SvW Aug 25 '11 at 8:03
    
@SvenW.. Yes, I agree with that. Was actually reading it at lunch time and it seems nicely written. It sounds like I could write 1 single config file on the new vps and call fetchmail once and it will dispatch each remote account to a different local account (which would be perfect). It advises itself against running as root - do you think there would be any issue doing it as root since it's running only once? (don't really want to login into each local mail account to download the mail once.. ) –  Ben Aug 25 '11 at 10:40
    
Yes, one config file is sufficient, and running as root for this purpose is OK as well, this hint is more concerned with the daemon mode that fetchmail also supports or the call from a crontab. BTW, since this migration can be tricky to get right, I would suggest you make sure mails don't get deleted on the source machine and create some dummy accounts on the target machine where you will drop the mails and delete them afterwards if everything is working as expected. –  SvW Aug 25 '11 at 12:12
    
Yes, very good advice. I did notice the "keep" statement on the man page and I definitely will do tests and keep on the old server. Thanks for your help, I feel way more knowledgeable :) –  Ben Aug 25 '11 at 12:20
add comment

SvenW's answer was spot on helpful, thanks!

For those interested here are the details of the command to run.

Notes:

  1. i'm running this as root on the new server

  2. A fetchmailrc file is not necessary, can be all done with one command (since it's once off it's good)

  3. Password are not passed on the command line, so the first step is to create a .netrc in the home folder with the following syntax:

    machine server.com

    login email@server.com

    password thepassword

If you need multiple, just keep adding them in the netrc file.

  1. Run this command

    fetchmail -v -a -k -p APOP -S localhost --smtpname email@server.com -u email@server.com server.com

    -v makes it more verbose, helpful

    -a grabs everything (including read email)

    -k keep mail on the old server (up to you, may be good for testing)

    -p the protocol to use. APOP worked for me, but check the fetchmail documentation

    -S (that's uppercase S) the destination server (localhost since i'm already on the machine)

    --smtpname the local recipient (should be the same mailbox as the source server)

    -u the username to connect to the remote server (some servers use email@server.com, some just email, or sometimes something else)

    and finally the last server.com is the address of the remote (old) server

for testing you can also add a -c parameter, that checks but doesn't retrieve. Good way to check if the setup is correct

share|improve this answer
add comment

pop2imap is designed to transfer messages from a pop3 server to an imap server incrementally. Same usage as imapsync.

http://www.linux-france.org/prj/pop2imap/

pop2imap \
   --host1 pop3.troc.org --user1 foo --password1 secret1 \
   --host2 imap.trac.org --user2 bar --password2 secret2
share|improve this answer
    
Thanks for the suggestion. Managed to do it with fetchmail but i'm sure some others will find that tool handy –  Ben Aug 30 '11 at 0:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.