HomeArticlesEmacsWanderlust Email ClientConfigure Email Folders

Configure Email Folders

Unlike other email clients on our planet, Wanderlust doesn't have the notion of “email account”.  To Wanderlust, all we have are “email folders”.  It took me some time to grasp the difference.  Wanderlust is (by default) most suitable if you use only one email address, but that's not my case.  Anyway, here's some information on how to configure folders.

First, the basics

WL stores the folders information in the file “$HOME/.folders” (dot folders).  Here's the syntax for one IMAP folder:

%INBOX:johndoe/clear@mail.domain.com:993!   "INBOX"

The above tells WL that we have an IMAP folder (starts with “%”), on the server named “mail.domain.com”, using “clear” (plain) authentication, user name “johndoe”, port “993” and should use secure sockets layer (SSL) when connecting (ends with “!”).  Additionally, the string "INBOX" at the end specifies how this folder should be named locally.

It took me one hour to make it work because, for some reason, I kept writing “plain” instead of “clear” in the authentication token.  The error message is meaningless (said “authentication failed”, it would have been a lot more helpful to say “no such method: plain”), so be careful how you write these entries.

Folder groups

Let's complicate things a bit, shall we.  If you have lots of folders and describe each one in the way above, you'll get a flat list.  That's quite bad, we need to organize a bit.  Suppose you have multiple folders and subfolders on your IMAP server, in order to make WL display them properly you need to do that:

%INBOX:johndoe/clear@mail.domain.com:993! "INBOX"
INBOX {
  %INBOX/Family:johndoe/clear@mail.domain.com:993! "Family"
  %INBOX/Work:johndoe/clear@mail.domain.com:993! "Work"
  Work {
    %INBOX/Work/BugReports:johndoe/clear@mail.domain.com:993! "Bug Reports"
  }
}

So what it does, it creates in WL this folder structure:

  • INBOX (actual folder)
  • INBOX (group holding subfolders)
    • Family (folder)
    • Work (folder)
    • Work (group)
      • Bug Reports (folder)

So you get both the folder and the group.  I'm not quite happy about it, but that's life.  If you only put the group INBOX (but not the folder), there will be no way to read the messages from INBOX.  Oh well.

Automate it

I have something like 50 IMAP folders in 2 accounts.  I thought it's awkward to manually describe each of them like that, so I wrote a little Perl script to do it.

Create a directory named WL in your $HOME and save this script there.  Make sure Net::IMAP::Simple is installed (in Debian, apt-get install libnet-imap-simple-perl).

Next, create a file named gen-folders.rc (in the same directory) and put your account information there, one per line, in this format:

imap-ssl://userID/password@mail.domain.com:port  AccountName

You can use "imap" instead of "imap-ssl" if you don't want to use SSL to connect to server.  You can strip ":port" if you wish (but in my experience, it's best if you add it, even if it's a standard port).  "AccountName" is a top-level group folder that will contain as subfolders any IMAP directories from that account.

After you create this file, run gen-folders.pl and put the output in ~/.folders.  There you go, have all folders from the start.

Note it's possible to edit (i.e. reorder, rename, add, remove) these folders directly in Wanderlust, so you'll normally want to generate it only once.

It's now time to start Wanderlust.