Help - Search - Members - Calendar
Full Version: Transferring Mail from Server to Server using Fetchmail
The Planet Forums > System Administration > HOWTOs
webbcite
Transferring sites from one server to another can sometimes be a pain in the butt...especially when dealing with email and propagation. You don't want to loose any email on the old server or have to try to get the customer to setup two email accounts to retrieve email from both servers during propagation. Well that is where fetchmail can come in handy.

For detailed information on fetchmail, see 'man fetchmail'

This HowTo will show you how to setup fetchmail to retrieve POP3 email from the old server and deliver it to the new servers user.

First you need to make fetchmail available to the virtual site.

Install Madsere's ensimpkg program and run addpkg for fetchmail on the domain.

fetchmail also uses 'uname', so you will either need to copy /bin/uname to the virtual sites /bin directory or create a link.

Once you have done that, you can start setting up the .fetchmailrc file that will be used to fetch the mail.

The user will need SSH access.

su user@domain.com

create a file called .fetchmailrc in the users home directory

cd

This will put you in the users home directory

vi .fetchmailrc

enter the following in the file


poll ip.of.old.server proto pop3
user "oldserveruser" with pass "oldserverpass" is "username@domain.com" here
keep
fetchall


This tells fetchmail to poll the old server IP using the pop3 protocol. Access mail for the old server username using the old server's password and deliver the mail to the new server user "username@domain.com". "keep" tells fetchmail to leave the mail on the old server. You can also use "flush" which will remove the mail. Problem with flush is that if there is an error during the transfer and the mail doesn't get delivered, it will be removed from the old server and lost. I have found that leaving it set to "keep" is a little safer and I can go to the old server and delete the emails manually when I have verified that the mail was transferred successfully. "fetchall" tells fetchmail to get all emails in the old servers account.

That is pretty much it. Now it is just a matter of running fetchmail when signed in as the user on the new server.

fetchmail

That's all there is. Fetchmail has a number of other useful features such as running in daemon mode which can be set to check for mail on the old server every X number of seconds.

When in doubt "man fetchmail"
reallynicejerk
oh man, wish I would have known about this a few days ago, just had this very same issue with a friend sharing my server, he wanted to transfer e-mails from his old host to the new server and tried to ftp files and was having a hard time, this probably would have done the trick.
unwaw
if you use qmail with Maildirs and have already changed MXs you can

find $dirname -name "*`hostname`*" | qmail-inject

Regards.
monkeyman
Very handy, and makes it much simpler for a client when they are transfering domains.



Thanks webcite!

Lee

icon_biggrin.gif
inquisitive
Very Nice...Mail Migration from one server to other would now be a very easy job...Great Work Madsere & Webbcite icon_biggrin.gif
localbznet
Hi,

I just got a new plain p4 redhat 7.2 server.

I wonder if you or someone can show me how to set up new email accounts so that I can receive emails into my server?

Best Regards,
ideanet
Hi,
but if I'm a server administrator, I can't fetch all mailbox of all virtual hosting that I have on my old server?
kamihacker
QUOTE
Originally posted by ideanet
Hi,  
but if I'm a server administrator, I can't fetch all mailbox of all virtual hosting that I have on my old server?


if the passwords are blocking you from doing just change them, remember your customer don't need that account anymore

regards
ideanet
Hi kamihacker,
it is true:D

Thanks
ideanet
Another question: it's possible to reset or change the users password via script without know the name of users hosted on Ensim server?
L.J
QUOTE (ideanet @ Feb 17 2005, 12:07 AM) *
Another question: it's possible to reset or change the users password via script without know the name of users hosted on Ensim server?



This was nearly the solution for me. I'll have a search for that program in a minute to see if it's been updated but I need to move across the "sent items" folder as well! Plus can anyone tell me if moving the email from the old server onto the new one means you lose all the timestamps etc... of the emails?
dvanausdoll
Why not just add the an SMTP line per domian into the old servers /etc/mail/mailertable after disabling the mail services on all domains being moved?

You can also forward pop3 and imap connections to insure a smooth transition for any users with lagging DNS info.

Just my 2 cents...
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.