Managing IMAP accounts with Trojitá

scanrail, 123RF

scanrail, 123RF

Netting Mail

Gone are the days when we read email solely sitting at our computers. To read messages on the move, we now have IMAP, which has completely displaced POP. Trojitá makes IMAP easy, even with accounts with big folders.

The large KDE SC and Gnome desktop environments include extensive groupware functions with KMail and Evolution. However, until recently no mail program has existed for the Qt environment that just manages mails, such as Claws Mail and Sylpheed do for GTK.

In 2006, Jan Kundrát developed Trojitá [1] as a Qt/C++ application [2] based on an earlier attempt in Python. He describes the background in a series of blog articles [3], including what he didn't like about other IMAP clients and what motivated him to start his current project [4].

Kundrát explained why simply improving KMail, which at the time was not yet based on Akonadi [5], wasn't the answer. His reason was primarily the current IMAP structure, which was used in many places, and still is, but has some flaws. Even today, KMail still doesn't support deleting emails from other IMAP clients with the corresponding flag [6].

Unlike Claws Mail and Sylpheed, Trojitá is limited to IMAP and doesn't support POP3 accounts. It also doesn't maintain any plugins except for a single one for password storage security. These restrictions, however, make it easier to develop and make it a fast and efficient client. The software was originally integrated with Ubuntu Touch, but Jan Kundrát removed this integration in October of 2014 [7] because the Touch developers pursued their own fork, Dekko [8].

The central promise of the developer is that Trojitá opens large mailboxes quickly and uses both main memory and CPU efficiently. To do this, the program uses several advanced IMAP features, such as QRESYNC and CONDSTORE for fast mailbox synchronization, and CONTEXT=SEARCH for live search [9].

Unlike programs that began as POP3 clients, Trojitá was especially designed from the outset as an IMAP client. The latest release, version 0.4, promises even further improvements.

According to developers, it synchronizes large mailboxes up to 10 times faster than other clients and saves up to 40 percent memory [10]. Among the program's special features is loading only as much data as the users' view requires, thus you can open mailboxes with 100,000 emails without having to wait for the software to create a full index [11].

Installation

The developers offer the program through the openSUSE Build Service [12] as a package for Fedora, RHEL/CentOS, openSUSE, Debian, and Ubuntu, as well as the source code [13]. Nightly builds [14] provide several enhancements for version 0.4.1. Thanks to Qt's platform independence, Trojitá also runs on Windows and Mac OS X. However, the website currently refers only to the Windows installation.

To take a look at the full functionality, the nightly builds are the best option, because they enable encrypted password storage through Qt keychains [15], unlike the released version.

Keychains use the Gnome Keyring or KWallet Manager for KDE, thereby also supporting Windows and MacOS X. The nightly builds are in English only, with the released version interface translated into other languages.

The translated versions come from a different repository and the openSUSE Build Service currently doesn't run the Python script that loads them. This article, therefore, is based on the English-only version.

To install with the package manager, click your distribution's logo and follow the instructions. For Ubuntu 14.04, the first line in Listing 1 adds the release GPG key to the APT keychain. Line 1 configures the corresponding repository. Using the package manager, you then install either the trojita package for the current release or trojita-nightly for the nightly builds. For secure password storage, also install the trojita-plugin-qtkeychain package.

Listing 1

Install Using Package Manager

$ wget -q -O- http://download.opensuse.org/repositories/home:jkt-gentoo:\
  trojita/xUbuntu_14.04/Release.key | apt-key add -
$ sudo sh -c "echo 'deb http://download.opensuse.org/repositories/home:/jkt-gentoo:\
  /trojita/xUbuntu_14.04/ /' >> /etc/apt/sources.list.d/trojita-nightly.list"

If you later want to switch from the nightly build to the release version, uninstall the trojita-nightly package first. If you don't, you will get a missing conflict error message that prevents concurrent installations. The same applies if you want to install the nightly after installing the release build.

Another option is building the software directly from the sources (see the "Compile It Yourself" box), which you could do if the nightly build is not the latest version.

Compile It Yourself

To begin, download the Trojitá source code using the first line in Listing 2. If you want to update it later, use the git pull command. Debian and Ubuntu users should get the required dependencies for the build using apt-get build-dep trojita . You get the current localized versions from the subversion repository using python l10n-fetch-po-files.py .

Trojitá requires Cmake, Qt, Zlib, and for secure password storage, it needs Qt Keychain. For Debian and Ubuntu, you install the packages cmake , libqt4-dev , qt4-dev-tools for Qt Linguist, libqtwebkit-dev , zlib1g-dev , libqtkeychain-dev and ragel . Then, change to the source code directory and configure the source code using the commands on lines 2 through 5 of Listing 2.

Once Cmake runs error-free, make -j4 creates the sources, substituting the processor core value for the number after -j . With sudo make install , the program then ends up in /usr/local . In our tests, it also required calling sudo ldconfig to make the system aware of the newly installed libraries.

For Qt5, you need the Debian packages qtbase5-dev , libqt5webkit5-dev , qt5keychain-dev , qttools5-dev , and qttools5-dev-tools for the Qt5 Linguist tools. Then, use cmake -DWITH_QT5=ON , if necessary deleting the CmakeCache beforehand.

To install in a different directory or make other settings, execute ccmake .. before the cmake and adjust the settings.

Because of a bug in Qt 5.3.1, Qt failed to start with this version. Trojitá did start with Qt 5.3.2 but crashed when clicking an email. The Qt Webkit used by Qt5 loaded the browser plugin for the X2go remote desktop solution in memory, even though it's a Qt4 plugin. This error was subsequently resolved in the Qt Webkit source code [16]. After removing the x2goplugin package, the Qt5 version of Trojitá finally ran (see Figure 1).

Because cmake doesn't create a make target for removal (uninstall ) but lists the installed files, you can uninstall using cat install_manifest.txt | xargs sudo rm . To build a Debian package, use the guide in README.Debian , which explains how to build Trojitá yourself based on the files for the openSUSE Build Service. In our tests, however, the dpkg-buildpackage -b command required the -rfakeroot option.

The build dependencies for the package are in the debian/control file under Build-Depends . The dpkg-buildpackage command shows what's still missing. The -b option is still required; otherwise, the command searches for a source code tarball that doesn't exist in a Git checkout. Even though the package includes version 0.3.90 in the filename, dpkg-buildpackage builds a (not exactly current) version 0.4.1 from July 7, 2014. To avoid going too deep into the Debian packaging, you're better off going with the package in the openSUSE Build Service, as this was current at publication time

Listing 2

Build Trojitá

01 $ git clone git://anongit.kde.org/trojita
02 $ cd trojita
03 $ mkdir build
04 $ cd build
05 $ cmake ..
Figure 1: Trojitá runs with Qt5, but you need to do a few things first to make sure it's stable.

Configuration

Configuring the mail client is easy in that you'll find all the settings under IMAP | Settings . On the General tab, use Add to add your name and email address. Trojitá provides the option of using multiple identities. Set Passwords to Secure storage via QtKeychain to store encrypted passwords. If you want to avoid HTML messages, activate Show plaintext emails instead of the HTML version .

Configure your accounts under IMAP (Figure 2). The program expects the usual information like server name, port, username, password, and encryption method. For Encryption , use the entry Use encryption (STARTTLS) or Force Encryption (TLS) . The latter uses IMAP port 993, and the former uses standard port 143 for encryption using STARTTLS – a method of initiating communication by means of encryption using Transport Layer Security (TLS).

Figure 2: Trojitá supports an IMAP account along with the usual options for encrypting the client-server communication.

Unlike KMail and Thunderbird, Trojitá currently supports one account at a time only. By using different profile startup files in Trojitá 0.4, with the --profilename option, you can supply a different profile name [8]; however, this isn't the best approach to creating multiple accounts.

Trojitá can start an IMAP server as a local process, such as the Dovecot server using SSH keys and the SSH agent using ssh mail.example.org dovecot --exec-mail imap . You also can have a local Dovecot on the laptop together with a synchronization program, such as Imapsync.

To send emails, specify under SMTP the server name, port, and encryption method. If the dialog says Trojitá is using port 25 for STARTTLS, you will have to modify it, because STARTTLS normally uses port 587. For SMTP authentication, as is now customary, enter the username and password.

Under Offline , you configure whether the software buffers messages and mailbox indexes, either permanently or for a certain number of days. The buffer is in a SQLite database in ~/.cache/flaska.net/trojita/imap.cache.sqlite . In our tests, it stored messages for 30 days and up to 76MB.

The program creates indexes for both the folder and the entire emails in cache. This approach helps mainly to unburden and separate the IMAP server and network connection from net emails. Trojitá provides the three options Offline , Expensive Connection , and Free Access in the IMAP | Network Access menu.

Proper Reduction

When using the application, you can see how much the developer has trimmed down the program. Even though Trojitá has a rudimentary register for frequently used addresses, it isn't a complete PIM suite and doesn't want to be one. It basically follows the structure of many mail clients: a menu bar and toolbar at the top, the list of folders on the left, and the list of emails and the view of one of their contents on the right.

Using the View | Layout menu, you can set the alternative Wide layout (Figure 3) that makes better use of the space on wider screens. However, this makes it harder to adjust the width of columns for subject, sender, date, and mail size. A handle is missing between the Subject and From elements for changing the column widths, and the others are a bit awkward. The setup is, however, good for a mailing list with two lines per email, similar to KMail [17].

Figure 3: Trojitá's wider view is well suited to modern laptops with panoramic displays. Unfortunately, it's a challenge to adjust the column widths.

The One at a time view shows the list of folders, the messages in each, or a single message, thereby saving space on smaller laptops or mobile devices. Trojitá somewhat unexpectedly adds new emails at the bottom of the list. Using Sorting , you have a few options to help you organize them. You can also sort by threads if you set a tree structure with Show Messages In Threads .

The Quick Search option proved to be quite useful. Among the 88,000 messages in the Linux kernel mailing list folder, Trojitá found the three util-linux release announcements in a matter of three seconds (Figure 4). Unfortunately, we couldn't find a cross-folder search during testing.

Figure 4: Fast and practical: a mailing list search in one-at-a-time view.

Especially appealing when viewing messages is the compact nature of headings, the ability to assign tags, and the appearance of mail quotes [18] with vertical-line separations. The program displays HTML emails with the standard formatting, and you can turn on external images. A zoom function is missing, however, which leads to HTML emails having too small a print to read easily on high-resolution displays. Also, a function is missing to copy mail addresses through a context menu to the address book.

The send window is also very sparse. At the upper left are the fields for the sender's identity and any number of recipients. Like KMail, Trojitá allows creating new fields. To the right is a button for adding attachments and a list of attachments, including the actual message text.

You can also use New Thread to open a new dialog or change whether the message goes to the sender, all recipients, or to a mailing list. The program also comes with some basic intelligence built in; on mailing lists with matching headers, messages go only to the list by default.

Performance

What about the program's performance and efficiency? In our tests, we let the software loose on an IMAP account with 200,000 emails, primarily those from mailing lists of open source projects. The largest folder was the kernel mailing list with nearly 100,000 emails.

The account was on a Dovecot server, one of the fastest IMAP MTAs, that saved its email in a Btrfs filesystem on a NetApp storage appliance. The test was limited to subjective impressions, because the server shared the infrastructure with other virtual machines, which made it hard to reproduce measurements. For a comparison, we accessed the same IMAP account with KMail 4.14.2 with Akonadi 1.13.

Trojitá was ready for use right after IMAP account configuration, and the access to the large folders was fast. Here, the program did well with its competitors. With KMail, Akonadi was first involved in loading all folder indexes after setting up the account, something that took an hour or more.

Trojitá showed no weaknesses when accessing the kernel emails folder. It loaded only a part of the index and not the whole thing. The program first ran in Free Access mode with a cache of 30 days. This proved to be a problem with quick folder changes or when scrolling through the list of messages. Trojitá loaded more of the index than the user could see to respond to requests more quickly.

Unfortunately, Trojitá didn't end old queries so that, when changing folders or scrolling through the message list, it took from 10 seconds to a half a minute waiting time while the IMAP server used the common memory to capacity. With threading enabled, where the application loads more contexts to show the participation in conversation threads, the effect was even more pronounced.

Once the data was stored, the client proceeded more quickly. Curiously, the Expensive Access option helped in a more expensive connection. Here Trojitá actually loaded only what the user wanted to see. The program updated the view in a matter of seconds, even when scrolling in the kernel mailing list folder. So, if you have a connection to a fast IMAP server, this option does work better.

KMail, in comparison, was also quite fast after the first scan when accessing the folder and its messages – unless Akonadi was strongly involved with background tasks, in which case it took somewhat longer. However, Akonadi also constantly ran in the background to resolve the IMAP account and store the folder indexes in the MySQL database. For large folders, KMail took some time to build the thread view fully, during which time the program was slow to respond.

Although Akonadi took considerable time with the indexes in this case of a spontaneous access to the IMAP account, Trojitá was significantly faster. To offset it, KMail provides a really useful and fast full-text search of the complete account with its Baloo tool, assuming Akonadi is running regularly in the background.

A comparison of a large IMAP accounts on Exchange showed no significant facts. Both KMail and Trojitá showed some wait times throughout, which is highly likely because of Microsoft's IMAP implementation that doesn't support many advanced commands.

Conclusion

In testing, we liked the Trojitá mail program because of its simple structure and high speed. Basic functions such as threading, message display, and folder searching are straightforward and solid. Especially appealing in tests was the elegant display of quoted text. If you want to read emails efficiently in a large IMAP account, Trojitá would make an excellent choice (see Figure 5).

Figure 5: Trojitá truncates long quotes – useful with top postings – and allows applying tags to messages.

Regarding functions such as supporting multiple accounts, full-text search across the entire messages, GPG support, and more, the program currently doesn't come close to other clients like KMail. In the current versions, the KMail-Akonadi duo was also convincing with larger IMAP accounts in comparison, provided Akonadi was running in the background.

Infos

  1. Trojitá website: http://trojita.flaska.net
  2. IMAP email client: https://projects.flaska.net/projects/trojita/files
  3. Jan Kundrát's Trojitá blog: http://jkt.flaska.net/blog/tags/trojita/
  4. Introducing Trojitá, a Qt IMAP email client: http://jkt.flaska.net/blog/Introducing_Trojit____a_Qt_IMAP_e_mail_client.html
  5. On Innovation, NIH, Trojitá, and KDE PIM: http://jkt.flaska.net/blog/On_Innovation__NIH__Trojita_and_KDE_PIM.html
  6. KDE-Bug 26986: https://bugs.kde.org/26986
  7. Removal of the Ubuntu-Touch code from Trojitá git: http://jkt.flaska.net/blog/Removal_of_the_Ubuntu_Touch_code_from_Trojita_git.html
  8. One week in and Dekko has 41 users: http://blog.dpniel.com/?p=31
  9. Trojitá, a Qt IMAP email client, and the Qt Developer Days: http://jkt.flaska.net/blog/Trojita__a_Qt_IMAP_e_mail_client__and_the_Qt_Developer_Days.html
  10. Trojitá 0.4 "Ukraine" is released: http://jkt.flaska.net/blog/Trojita_0_4__Ukraine__is_released.html
  11. Tagged pointers, and saving memory in Trojitá: http://jkt.flaska.net/blog/Tagged_pointers__and_saving_memory_in_Trojita.html
  12. OpenSuse Build Service for Trojitá versions: http://software.opensuse.org/download.html?project=home:jkt-gentoo:trojita&package=trojita
  13. Trojitá download: http://trojita.flaska.net/download.html
  14. Trojitá nightly builds: http://software.opensuse.org/download.html?project=home:jkt-gentoo:trojita&package=trojita-nightly
  15. Qtkeychain: https://github.com/frankosterfeld/qtkeychain
  16. KDE bug 340061: https://bugs.kde.org/340061
  17. KDE bug 340309: https://bugs.kde.org/340309
  18. New features in Trojitá 0.3.92: http://jkt.flaska.net/blog/Collapsing_long_mail_quotes_in_pure_CSS_and_other_new_features_in_Trojita_0_3_92.html

The Author

Martin Steigerwald works as a trainer, consultant, and system administrator at Teamix GmbH in Nuremberg. In addition to Linux training, he's concerned with the conception, installation, and maintenance of solid IT infrastructures based on Debian as well as second level support for Linux as a business desktop.