KMail In Depth

By: Carla Schroder
Thursday, January 13, 2005 09:48:16 AM EST
URL: http://www.linuxplanet.com/linuxplanet/tutorials/5707/1/

Masses Of Features and No Malware

KMail has long been my Linux email client of choice for a number of reasons: nice clean interface, easily customizable and configurable, stable, and more features than you can shake a stick at. Today we'll dig into migrating from other email clients, encrypting messages and key signing, and configuring multiple accounts and identities.

A quick review on message storage is in order. Most Linux mail clients store messages in one of two file formats: mbox or maildir. mbox is a flat file; all of the messages for a particular mail folder, such as your Inbox, are all stuffed into a single file. Maildir stores each message in a separate file. In these here modern times maildir is the format of choice, because it is faster and more fault-tolerant. And it is required for IMAP.

You should also know that KMail requires kdelibs, kdebase, and kdepim. It runs on Linux or most any Unix. The latest stable version is 1.7; this article covers versions 1.5 and up.

Review time is over; on to migration.

Migrating From Other Mail Clients

There are a number of ways to import messages from another mail client. IMAP is easy, because the message store and folders remain on the server. All you do is enter the account information in KMail: Settings -> Configure KMail -> Network -> Receiving -> Add. Check "IMAP" and click OK. This brings up a menu with three tabs: General, Security, and Filtering. The General options are self-explanatory. On the Security tab, click "Check what the server supports" to have KMail automatically identify whatever security the server supports. On the Filtering tab you can tell KMail to use your Sieve filters, if you have any.

Be sure to remember the Security tab--if your server encryption ever goes haywire, you can set your login to "None" and still fetch your mail. Non-securely, of course.

Migrating your POP folders from another mail client depends on what format the old mail client uses. mbox, the old Unix standard, is easy: Tools -> Import -> Import mbox Files.

Maildirs are easy; simply copy them to ~/Mail. Or you may point KMail to the folder containing your maildirs. First shutdown KMail. Then open ~/.kde/share/config/kmailrc, find the [General] section, and add a line like this: folders=/home/username/.foldername

A not uncommon problem is having both mbox and maildirs. (Right-click on your folders in KMail and click Properties to see what they are.) This is no big deal in ordinary usage, but for migration it's messy. The solution is to migrate each separately: copy over your maildirs, then import the mboxes. Another way to do this is to convert your mboxes to maildirs first. To do this, first create new maildir folders in KMail. Newer versions of KMail default to maildir; confirm this in Settings -> Configure KMail -> Misc -> Folders. And you can also select which format you want when you create the folder.

Next, copy the messages from the mbox folders into your new maildir folders. Verify that the copying worked, delete the old folders and you're done.

Encrypting Messages

This is the condensed version; we'll cover this in detail in a future article.

WARNING: Never ever share your private key! Only your public keys.

GPG serves two functions: encrypting messages to protect them in transit, and verifying the sender. You may use either of these, or both. You need GnuPG 1.2 or newer and GnuPG Made Easy (GPGME). While you're at it, grab KGpg, a nice graphical KDE utility for managing your keys.

First generate your private/public key pair:

$ gpg --gen-key

When you enter the comment, make it something to help you differentiate this key from any others you might have, such as "default email key." You'll be using the passphrase a lot- longer is better, like a silly sentence "this is my l33t passphrase."

Next, configure KMail. Settings -> Configure KMail -> Security -> Crypto Backends. Hit the "scan" button and KMail will find "OpenGPG (gpg)". Check everything it finds. Then go to the "Warnings" and "Composing" tabs and season to taste. Now go to Settings -> Configure KMail -> Identities, select an identity, and click "Modify." Configure your "Crytography" defaults. This is where your helpful comment pays off in helping you to select the right key. Go ahead and choose keys for both signing and encryption; you will always be able to choose what you want when you compose a message.

Now you can send an encrypted message. Compose a message to yourself, then click on the little padlock at the top of the message to encrypt it, or use the Options menu. When it arrives you'll have to enter your passphrase to read it. KMail remembers the passphrase until you close it down.

Public keys are used to "lock" or encrypt a message. Then the recipient uses their private key to decode the message. So to send someone an encrypted message, you need a copy of their public key. Conversely, anyone who wants to send you an encrypted message needs your public key to encrypt it. Use KGpg for this: Keys -> Export Public Key(s) -> Email. Email it un-encrypted, of course. To import a public key use KGpg, or

$ gpg --import keyfilename

Cryptographically Signing Messages

Cryptographically signing messages ensures recipients that the message really did come from you. For this to be meaningful, someone else must sign your key to verify that the key belongs to you, and that you are really you. That is why there are key-signing parties. See GnuPG Keysigning Party HOWTO for how to do this. Once it's set up you may send signed messages only, or signed and encrypted messages. Again use the Options menu, or look for the little quill pen icon.

When you are configuring Crypto Backends you may see the checkbox for S/MIME grayed-out. This occurs on Debian because S/MIME support is not compiled into GPGME, as of KMail 1.7. Why this is I do not know. You can still use encryption. When you send a message, choose "Inline OpenPGP (deprecated.)" Or you can build GPGME from sources and include support for S/MIME.

Configuring Multiple Accounts And Profiles

KMail handles multiple accounts and profiles with ease. For example, I have my public-to-the-world email address. Then I have my super-secret private account for family and friends that do not send me multiply-forwarded jokes or large attachments. And I create various other accounts for different purposes, such as one for my book. KMail let me do three things:

  1. Configure as many separate accounts as I like
  2. Configure multiple identities
  3. Route mail from different accounts into different folders
To configure your various accounts use Settings -> Configure KMail -> Network; you'll find both Sending and Receiving tabs here. Same old, all you need is your login and server information. Incoming mail for each account can be directed into any folder you like. Outgoing mail can also be directed into various folders; this is done when you create Identities.

Settings -> Configure KMail -> Identities is where it gets fun. This is where you set up signatures, return addresses, the user's mail account, and Sent Mail and Drafts folder locations. When you compose or reply to a message, you can select an identity from the dropdown menu in the message. (Use the View menu to control what fields and menus are displayed.)

That's just a fraction of what KMail can do. Watch this space for more.

Resources

GnuPG Keysigning Party HOWTO
Kmail home page

Copyright Jupitermedia Corp. All Rights Reserved.