Converting Sendmail and other mail servers to Kerio

As some of our readers know, I sell and support Kerio Mailserver (and other Kerio products also).

Very often a customer is switching to Kerio from some other messaging product such as Exchange. Kerio has conversion tools for migration from Exchange or (Mac) 4D Mail, but doesn't have a tool to migrate from Sendmail or other Unix based systems. That's probably because there are so many possibilities that it would be difficult to write a tool that would handle all conditions.


Hate these ads?

Drag and Drop

Often the easiest way to convert is just to let users drag and drop the messages they want from the old system to Kerio. Set up both accounts and let the users migrate whatever messages they wish.

Imapcopy

It's also possible to convert from one system to another using tools like Imapcopy. Contact me if you have a large number of users and need help generating a configuration file for this.

Scripting a conversion

If the above suggestions aren't appropriate, it's never very hard to migrate to Kerio Mailserver from just about anything. Kerio is easy to understand, and easy to bring data to.

Keep in mind when reading this that actual locations vary with operating system choice and that these can be over-ridden during installation. Therefore, the relevant files may not be at the locations I show here. Adjust your coding accordingly.

Users

If you have a small number of users, it may be easy to just use the Kerio Administration console to add the users. However, if you have more than a handful, it isn't difficult to script a transfer. Kerio stores user profiles in an XMLish file. Here's an example:



<config>
<list name="User">
  <listitem>
    <variable name="Name">Admin</variable>
    <variable name="Domain">foo.com</variable>
    <variable name="Account_enabled">1</variable>
    <variable name="Auth_type">0</variable>
    <variable
    name="Password">DE3:4d3736c7d71fdf60da6431b714634c8d
6a711cd60c0eba6ee0630d5458a8</variable>
    <variable name="PIN"></variable>
    <variable name="Rights">3</variable>
    <variable name="ForwardMode">0</variable>
    <variable name="HomeServer"></variable>
    <variable name="MailboxLocation"></variable>
    <variable name="Qstorage">0</variable>
    <variable name="Qmessage">0</variable>
    <variable name="MaxOutgoingMessageSize">0</variable>
    <variable name="DefSpamFilter">1</variable>
    <variable name="PreferredAddress"></variable>
    <variable name="ReplyToAddress"></variable>
    <variable name="Fullname">Administrator</variable>
    <variable name="Description"></variable>
  </listitem>
  <listitem>
    <variable name="Name">tony</variable>
    <variable name="Domain">foo.com</variable>
    <variable name="Account_enabled">1</variable>
    <variable name="Auth_type">0</variable>
    <variable
    name="Password">DE3:b5d44bda4338bb43a76de23c8
f72b87bd0c52615cd9c5770e61e51e580dc</variable>
    <variable name="PIN"></variable>
    <variable name="Rights">0</variable>
    <variable name="ForwardMode">0</variable>
    <variable name="HomeServer"></variable>
    <variable name="MailboxLocation"></variable>
    <variable name="Qstorage">0</variable>
    <variable name="Qmessage">0</variable>
    <variable name="MaxOutgoingMessageSize">0</variable>
    <variable name="DefSpamFilter">1</variable>
    <variable name="PreferredAddress"></variable>
    <variable name="ReplyToAddress"></variable>
    <variable name="Fullname">tony l</variable>
    <variable name="Description"></variable>
  </listitem>
  <listitem>
    <variable name="Name">fred</variable>
    <variable name="Domain">foo.com</variable>
    <variable name="Account_enabled">1</variable>
    <variable name="Auth_type">0</variable>
    <variable name="Password">DE3:b5d44bda4338bb43a
76de23c8f72b87bd0c52615cd9c5770e61e51e580dc</variable>
    <variable name="PIN"></variable>
    <variable name="Rights">0</variable>
    <variable name="Authorization">kms.own.domain.only</variable>
    <variable name="Groups">shop</variable>
    <variable name="ForwardMode">2</variable>
    <variable name="ForwardAddress">fredsmith@yahoo.com</variable>
    <variable name="HomeServer"></variable>
    <variable name="MailboxLocation"></variable>
    <variable name="Qstorage">1024000</variable>
    <variable name="Qmessage">300</variable>
    <variable name="MaxOutgoingMessageSize">307200</variable>
    <variable name="DefSpamFilter">1</variable>
    <variable name="PreferredAddress"></variable>
    <variable name="ReplyToAddress"></variable>
    <variable name="Fullname">fred smith</variable>
    <variable name="Description">shop manager</variable>
  </listitem>
</list>


My Unix and Linux Troubleshooting E-Book will show you how to
solve tough system problems!





<list name="Group">
  <listitem>
    <variable name="Name">shop</variable>
    <variable name="Domain">foo.com</variable>
    <variable name="Rights">0</variable>
    <variable name="Description">shop group</variable>
  </listitem>
</list>



<list name="Alias">
  <listitem>
    <variable name="Lhs">boss</variable>
    <variable name="Rhs">tony@foo.com</variable>
    <variable name="Domain">foo.com</variable>
    <variable name="Description">boss</variable>
  </listitem>
</list>



</config>


As Kerio might change that format to add new features, you should add at least one user manually, and also add a group and alias if you will need those immediately. Then examine the file to determine its format, and then write your code to transfer from whatever you have (passwd and group files or whatever).

You need to stop the Kerio Mail Server, create your users.cfg file, and then restart Kerio. Your user information will now show up in the Administration console software.

Messages

Messages are a little more difficult. The actual storage is very simple, but Kerio doesn't create the necessary directories for a user until the user receives mail. Again, Kerio may change the structure of these directories, so the easiest method is just to send a test message to at least one user and duplicate the hierarchy. Or create a group that includes all users and send a message to that group.

Actual messages are stored within folders using a simple hexadecimal naming scheme. For example, here's simple code that will read a "mbox" format mail file and put it out to individual Kerio files:



#!/usr/bin/perl
$user=shift @ARGV;
$out=0;
open(MBOX,$user);
system("mkdir -p /opt/kerio/mailserver/store/mail/admin/$user/INBOX");
while(<MBOX>) {
   if (/^From /) {
      close O;
      $out++;
      $message=sprintf("%0.8x.eml",$out);
      open(O,">/opt/kerio/mailserver/store/mail/admin/$user/INBOX/#msgs/$message")
      or die("User has no directory yet.  Send a test message to
      create their hierarchy\n");
   }
   print O;
}
close O;
rename "/opt/kerio/mailserver/store/mail/admin/$user/INBOX/index.fld",
"/opt/kerio/mailserver/store/mail/admin/$user/INBOX/index.bad";


Again, you'd stop the Kerio Mailserver, run your code, and restart. For simplicity, this code ignores setting proper ownership and permissions on the created files, and of course how to do that is a little OS dependent also. On a OS X box, these would be 600, owned by root:



-rw-------   1 root  apl  276 Apr 21 10:06 00000001.eml


The code also doesn't attempt to set modification time - again, OS dependent and you may not care. If you do, you'll need to extract the date from the message and use that information to modify the time stamp of the file you create.

Notice the rename of "index.fld". That triggers the mailserver to update its indexes, so can also be used to remove unwanted messages (for example for a user who refuses to clean out a junk mail folder). Just stop the mailserver, do whatever you need to do, rename the appropriate "index.fld" files, and it's ready to run.

Kerio is a powerful, full featured mail server, but they have made it easy for you to work with it from the outside. The use of text files and reindexing of messages gives you the control you need.


Technorati tags:







-
Google Friend Connect users can
comment on this page here


Enter your email address for automatic notification of new posts here
(be sure to whitelist 'feedburner.com' if you use spam filtering)

Or use any RSS reader

Delivered by FeedBurner

cartoon
Need eyes on the ground at your customer's site?
Installation and light training Boston and New England
Reliable and experienced, punctual and professional.


Views for this page
Today This Week This Month This Year  Overall
115152,092 5,759

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

pavatar.jpg
More:
       - Mail
       - Kerio
       - Kerio Pricing




Unix/Linux Consultants


UBB Computer Services Support for Openserver, Unixware and Linux. Windows integration with Unix/Linux servers. Hardware, Backup and Networking issues. Located near Sacramento CA, we provide onsite support throughout Northern CA and Nationwide via remote access. We are a SCO Authorized Partner and a Microlite BackupEdge Certified Reseller.


larryi@ccamedical.com SCO OS5, Debian Linux, RedHat Linux, MySQL, Apache, AJAX development using dXport/dL4/Unibasic, Windows Connectivity, Sharing Resouces, Automation, Shell Scripting


http://echo3.net/ Unix/Linux Custom Applications, Web Hosting, C/C++ Programming Courses



Twitter
  • Dec 3 14:01
    Just went out and added more bungee reinforcement. That ought to hold it..
  • Dec 3 13:58
    I'm second guessing myself on how I bungeed the cover on my golf cart for winter storage. Wondering if high wind could rip it off..









Change Congress