Click here to Skip to main content
15,880,891 members
Articles / Operating Systems / Linux
Article

Cross Platform Mail Migrations

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
25 Apr 2009CPOL2 min read 13.2K   7  
Moving Linux mail to Windows mail

Introduction

Historically, moving from a Linux mail system- such as Postfix/Dovecot -to a Windows mail system- such as Smartermail -was not a seamless process. Mail formats are so largely different that it is next to impossible to copy mail over. Users were best suited to POP3 all mail off the Postfix server and then connect to the Smartermail server to achieve a complete migration. But how useful is this when you have possibly 1GB of mail? Or is this scalable if you have a company with many non-technical users?

Using the Code

A viable solution is to use a neat little Perl module named 'imapsync'. As the name suggests, IMAP must be enabled on both the source and destinations server. This module can be downloaded from one of the distributions here. A number of Perl modules are required as well:

  • Mail::IMAPClient 2.2.9 only
  • Digest::MD5
  • Term::ReadKey
  • IO::Socket::SSL
  • Date::Manip
  • Digest::HMAC_MD5 (optional)

All these modules can be obtained from CPAN's site. Once installed on the Postfix server, make sure you can telnet to the destination server on port 143. If any IPtables or firewall rules are blocking IMAP communications, obviously imapsync will error out.

For each user, you can then run a command like:

bash # imapsync --host1 localhost --user1 system_name 
	--password1 source_password --host2 destination_IP --user2 email_address 
	-password2 destination_password --authmech1 source_authmethod 
	--authmech2 LOGIN --prefix2 "" --sep2 "/"

Points of Interest

Note that the users must be present on the source and destination server already. Imapsync will not create any users. The source and destination users also do not necessarily have to be identical. But it is important to use the system name if the Postfix user is not a virtual user. The source's authentication method can be looked up in /etc/dovecot.conf under 'auth default'. More than one may be present. Generally 'PLAIN' or 'LOGIN' is used. Dovecot is good at announcing its namespace when a connection occurs, but Smartermail is not. We can specify this with the prefix2 and sep2 parameters.

For increased security, password1/password2 can be replaced with passfile1/passfile2 and a path to file so passwords on not visible to other users using the ps command. Other advanced features can be used such as inclusions and exclusions using regular expressions. Age filters can be placed on messages if you are looking to possibly sync the last day's mail everyday on a cron job. Delete parameters can also be used to effectively 'move' the mail instead of copying it. Have fun!

History

  • 22nd April, 2009: Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer HostMySite.com
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --