Nov 01

Import mails from a non cPanel server

It’s easy for us to import emails over between two cPanel servers, no matter we are migrating 50 or 100 accounts or so, its an easy job to do via WHM or even via backend of cPanel servers. But what if your task to migrate over all emails from a non cPanel server. aahh now you are in trouble!!! 😛

But trust me, you can do that easily with “imapsync”. Following is the command that I did to import mails of email account from a non cpanel.

suppose you want to migrate userx account on server sourceserver.com to userx account on destinationserver.com

====
imapsync –host1 sourceserver.com –user1 userx@domain.net –password1 enterpasshere –host2 destinationserver.com –user2 userx@domain.net –password2 enterpasshere –regexflag “s/\Forwarded//g” –noauthmd5 –syncinternaldates
====

you will see lot of things going on as below in the screen which is a sync process betweeen the two mail servers, wait for a while to complete and then you are done.

============
msg INBOX/208 {34910} copied to INBOX/445
msg INBOX/209 {81261} copied to INBOX/446
msg INBOX/210 {77615} copied to INBOX/447
msg INBOX/211 {10423} copied to INBOX/448
msg INBOX/212 {7092} copied to INBOX/449
msg INBOX/213 {13977} copied to INBOX/450
msg INBOX/214 {57403} copied to INBOX/451
msg INBOX/215 {75258} copied to INBOX/452
msg INBOX/216 {54282} copied to INBOX/453
msg INBOX/217 {77174} copied to INBOX/454
msg INBOX/218 {3298} copied to INBOX/455
msg INBOX/219 {48916} copied to INBOX/456
msg INBOX/220 {19315} copied to INBOX/457
[INBOX.Drafts] -> [INBOX.Drafts]
[INBOX.Junk] -> [INBOX.Junk]
[INBOX.Sent] -> [INBOX.Sent]
[INBOX.Trash] -> [INBOX.Trash]
++++ End looping on each folder
++++ Statistics
Transfer started on : Fri Nov 1 15:47:37 2013
Transfer ended on : Fri Nov 1 15:48:19 2013
Transfer time : 42 sec
Messages transferred : 232
Messages skipped : 0
Messages found duplicate on host1 : 0
Messages found duplicate on host2 : 0
Messages void (noheader) on host1 : 0
Messages void (noheader) on host2 : 0
Messages deleted on host1 : 0
Messages deleted on host2 : 0
Total bytes transferred : 16188117
Total bytes duplicate host1 : 0
Total bytes duplicate host2 : 0
Total bytes skipped : 0
Total bytes error : 0
Message rate : 5.5 messages/s
Average bandwidth rate : 376.4 KiB/s
Reconnections to host1 : 0
Reconnections to host2 : 0
Memory consumption : 115.4 MB
Biggest message : 3019767 bytes
Memory/biggest message ratio : 40.1
Detected 0 errors
============

Before everything you need to ensure imapsync is installed in server. If not just install it using yum.

=====
yum install imapsync
=====

You may require the following perl modules to install in the server.

=====
Mail::IMAPClient 3.34
IO::Socket 1.31
IO::Socket::INET 1.31
IO::Socket::SSL 1.955
Digest::MD5 2.53
Digest::HMAC_MD5 1.01
Term::ReadKey 2.30
Authen::NTLM 1.09
=====

For their installation, just go to cpan prompt and install them one by one.
For eg:

=====
[~]# cpan
cpan> install Mail::IMAPClient
=====

Please note if you are trying to import mails from pop accounts, them imapsync may not work. Such cases you can refer to poptoimap tool. Please read these:

http://www.linux-france.org/prj/pop2imap/pop2imap
http://imapsync.lamiral.info/FAQ

Leave a Reply

Your email address will not be published.