---
author: marco
categories:
- Utilities
date: "2005-06-18T17:32:27Z"
title: Configuring Fetchmail -> Postfix -> Cyrus -> IMAP
---

A nightmare over several days. I had set my mind that a local store was no good, because I needed to be able to access my email from outside the apartment, and decided that IMAP would be the way to go.

Technically, what I needed to do was to take the mail I got from my outside provider and download it to my server (this one). Then I needed to pass that email to an IMAP server, finally to get to it from the outside world. This seems stupid at first, but I run a dozen filters on my email, so that it makes very little sense for me to access the email directly on my ISP’s site.

  I set my mind on the following flow (that pretty much was determined by the way SuSE does things):

1. <span style="font-weight: bold;">fetchmail</span> would download the email from the ISP in a cron job
2. <span style="font-weight: bold;">postfix</span> would deliver said email on
3. <span style="font-weight: bold;">cyrus-imapd</span> would make it available

As mentioned, after a few days everything started running smoothly – but initially it was quite the ordeal.

# Fetchmail

Fetchmail configuration was pretty straightforward. That’s probably because I have done it before; but even where not, you really need to know only one thing in addition to the mailbox credentials: the syntax of the configuration file.

Check the files /etc/fetchmailrc or ~/.fetchmailrc (as root). There you probably will already find a line that looks like this:

poll "server.domain.com" protocol AUTO : user "john" there with password "pwd" is "smith" here ;

The only thing you need to watch out for is that the remote user and password match what you enter when you check email on the remote server. The <span style="font-style: italic;">here</span> account ("smith" in the example) is the local user you would like email delivered to.

Once you have written the file, use cron to check for email on a regular basis. Check the man page, or simply follow these exact steps:

1. type ‘crontab -e’
2. type ‘i’ (for insert)
3. type ‘\* \* \* \* \* fetchmail’
4. hit Escape
5. type ‘:wq’

That’s five stars in the fetchmail line. If you are not familiar with UNIX, you probably have no idea what you just did, but that really doesn’t matter.

# Postfix

Admittedly, Postfix was the worst of it all. I managed to disconnect both fetchmail and cyrus from it, and to send my whole email system into a deep, deep tailspin. Finally, I understood a little more, and I decided it would make so much more sense if configuration files in UNIX were structured better, instead of being endless lists of argument/value pairs.

Let’s make it short: you will have to modify two files:

- /etc/postfix/master.cf
- /etc/postfix/main.cf

(One could question the wisdom of calling one file ‘master’, the other ‘main’ – which one’s the real master, which one the real main?)

Again, regardless. All you need to do here is make sure the <span style="font-weight: bold;">last</span> line with ‘mailbox_transport’ in main.cf says ‘cyrus’. Then you go to master.cf and make sure the line that says ‘cyrus’ in not commented out.

Ok, this is not really for beginners. But there is a really good intro in the documentation. Look for it under /usr/share/doc. Now restart the server by issuing ‘/etc/init.d/postfix reload’, and you are ready to go.

# Cyrus

This should have been the most painful of the three, but it really was. 🙂

You start with the usual ‘apt-get install cyrus-imapd’. You will need to install ‘cyrus-imapd-utils’, too, otherwise you can’t create the mailboxes.

Once everything is running, check the status of the server or just start it like this: ‘/etc/init.d/cyrus-imapd start’

Now everything should be fine. Except that you need to create your mailbox. To do so, you first have to assign a password to the user ‘cyrus’. (For which you probably need no help). Then you log on to the administration tool: ‘cyradm -u cyrus localhost’

Ignore the prompt and type: ‘cm user.foo’. That’s short for <span style="font-style: italic;">create mailbox for user foo</span>. Of course, you’d change <span style="font-style: italic;">foo</span> to something else if you wanted a different user name.

That’s it!