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.

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 Kerio's free Imap migration tool. Contact me if you have a large number of users and need help generating a configuration file for this.

Kerio tools

Kerio has conversion tools for imap and Exchange.

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:

Kerio now has a csv import bulit in: Import Users

<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">[email protected]</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>

<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">[email protected]</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.

Kerio now has a csv import bulit in: Import Users

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.



Got something to add? Send me email.





(OLDER) <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> -> Converting Sendmail to Kerio




Increase ad revenue 50-250% with Ezoic


More Articles by

Find me on Google+

© Anthony Lawrence



Kerio Connect Mailserver

Kerio Samepage

Kerio Control Firewall

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.

Contact us





Yeah, it's obsolete, clunky, insecure and broken, but people still use this stuff (Tony Lawrence)

Technology is anything that wasn’t around when you were born. (Alan Kay)








This post tagged: