Welcome to WebProNews Breaking eBusiness and Search News
Advertise | Newsletter | Sitemap | News Feeds News Feed 
 WebProNews Search Part of the iEntry network iEntry inc. 

Transferring Mail To A New Mail Server

A.P. Lawrence
Expert Author
Published: 2005-01-18

WebProNews RSS Feed

Sometimes we just have to move on. Your current mail server may just not be meeting your needs, so you've put up something new. But what about old mail? If your servers are identical (Sendmail to Sendmail, etc.) or use the same mailbox storage format, you may be able to just transfer files directly. If not, read on..

If everyone uses POP, there's usually not much to transfer, and if you can shut off incoming mail and just wait long enough for everyone to pop their mail, there won't be anything. But many people now use IMAP.

It's actually sometime useful NOT to transfer anything. Many users let their mailboxes build up without ever deleting unneeded messages. If you can leave the old server on the network, they can always access their old mail if they need to, but they (and you) may find after a year or so that nobody ever has. You might then archive the messages "Just in case" and take down the old server.

If you do want to transfer messages, it can be as simple as running command line tools. The first thing to do is to set the old server to forward all mail to the new server. Exactly what you do to accomplish that depends on your server, but it should be easy. For sendmail, you'd set SMART_HOST and MAIL_HUB, or edit the aliases file and forward each user. For SME server, set the "Delegate Mail Server" in the Server Manager.

Transferring existing mail depends on the format it now uses. For example, Qmail stores messages in individual files. On an SME server (which uses Qmail) you could transfer "tony"'s current mail with just this:

cd /home/e-smith/files/users/tony/Maildir
for i in *
cat $i | /var/qmail/bin/qmail-inject

Repeating that for each directory would move all mail to the new server. However, it all ends up in the user's INBOX unless that server can apply rules to determine where to file it. To assist that, you may want to use a perl program instead. Something like this:

use Mail::Mailer;

foreach (@stuff) {
$from=$_ if /^From:/;
$to=$_ if /^To:/;
$subject=$_ if /^Subject:/;
last if $subject;
$from=~ s/From: //;
$from=~ s/$from=~ s/>//;
$to=~ s/To: //;
$to=~ s/$to=~ s/>//;
$subject=~ s/^/*** FILE ME IN CUSTS ***/;
$mailer->open({From =>$from,
     To => $to,
     Subject => $subject,
     }) or die "Can't open $!n";
foreach (@stuff) {
   print $mailer $_;

You'd adjust the modification to Subject appropriately, or add entirely new headers if desired.

If your mail is stored in Unix mailbox fashion, you need something to read the messages and break them up. While you could read the mailboxes directly, it's more portable to use tools like POP:

use Net::POP3;
$pop=Net::POP3->new('') or die "$!";
foreach $msg(keys %$messages) {
foreach (@$message) {
#same basic idea as above,

You may need to get Net::POP3 from CPAN. There are similar modules for IMAP.

Bruce Garlock suggested that Mailsync might also be useful here.

*Previously published at APLawrence.com

Receive Our Daily Email of Breaking eBusiness News

About the Author:
A.P. Lawrence provides SCO Unix and Linux consulting services http://www.pcunix.com

WebProNews RSS Feed

More Articles

Contact WebProNews


Targeted Information for Business
WebProNews is part of the iEntry network

Internet Business: Marketing: Small Business:
WebProNews MarketingNewz SmallBusinessNewz
WebProWorld AdvertisingDay PromoteNews
EcommNewz SalesNewz EntrepreneurNewz

Software: Search Engines: Web Design:
WebMasterFree Jayde B2B DesignNewz
NetworkingFiles SearchZA FlashNewz
SecurityConfig SearchNewz WebSiteNotes

Developer: IT Management: Security:
DevWebPro ITManagement SecurityProNews
DevNewz SysAdminNews SecurityConfig
TheDevWeb NetworkingFiles NetworkNewz

The iEntry Network consists of over 100 web publications reaching millions of Internet Professionals. Contact us to advertise.

 Advertise | Contact Us | Corporate | Newsletter | Sitemap | Submit an Article | News Feeds
 WebProNews is an iEntry, Inc. ® publication - $line) { echo $line ; } ?> All Rights Reserved
About WebProNews
WebProNews is the number one source for eBusiness News. Over 5 million eBusiness professionals read WebProNews and other iEntry business and tech publications.

WebProNews provides real-time coverage of internet business.

Free Email Newsletters:
WebProNews SearchNewz
WebProWorld DevWebPro
Marketing SecurityNews
Plus over 100 other newsletters!

Send me relevant info on products and services.

Ten most recent posts.

Featured Software

WebProNews in the News
View all recent mentions of WebProNews from around the world!

Recent Articles On ...
Google eBusiness
Yahoo Ask Jeeves
MSN Blogs
Search Engines Blogging
Affiliate Programs Marketing
eCommerce Advertising
eBay Sun Microsystems
AOL Adsense
Microsoft Adwords
Oracle IBM
Amazon Apple
SEO iPod
Adsense XBox
PR Adobe

iEntry.com WebProWorld RSS Feed WebProWorld Contact WebProNews Print Version Email a friend Bookmark us