Tag Archives: cyrus
Simple e-mail config with postfix and Cyrus IMAP

This is a quick’n’dirty tutorial on how to get e-mail working on a basic Linux (Redhat/Fedora/CentOS) installation like the one you may get if you deploy a node in AWS with a predefined AMI (Amazon Machine Image).

The Redhat linux distributions come by default with postfix as MTA (Mail Transport Agent) and Cyrus IMAP as the MDA (Mail Delivery Agent) so this small tutorial is focused on these. Having the packages installed we can go to the configuration files:

  • /etc/postfix/main.cf: the postfix file, where we configure which e-mails we accept and what to do with them.

  • /etc/imapd.conf: settings for Cyrus IMAP – where to look for the mailbox passwords, what authentication mechanisms should be supported for pop/imap.

  • /etc/sasl2/smtpd.conf: for smtp authentication, if an e-mail relay is required (NB: this file can also be located in /usr/lib/sasl2/smtpd.conf).

There is also another file, /etc/cyrus.conf that usually contains the proper defaults upon installation so there may be no need to look into that. It contains settings like the supported protocols (pop3/pop3s/imap/imaps) and the lmtp socket location (the interface between postfix and Cyrus IMAP).

In the postfix configuration file, the following settings are essential:

# cat /etc/postfix.main.cf
mailbox_transport = lmtp:unix:/var/lib/imap/socket/lmtp
virtual_transport = $mailbox_transport
virtual_mailbox_domains = /etc/postfix/virtual_domains
virtual_mailbox_maps = hash:/etc/postfix/virtual_maps

Explanation: the e-mails for the domains specified in virtual_mailbox_maps are to be, before anything else, accepted for further processing. The final mailbox must be determined by looking into virtual_mailbox_maps (if no such mailbox is determined, some error will be returned to the sender). The effective delivery should be done through the socket specified at mailbox_transport.

Some example file contents:

# cat /etc/postfix/virtual_domains

# cat /etc/postfix/virtual_maps
john.doe@brainware.ro	brainware.ro/john.doe

The “virtual_maps” file is to be “hashed” with postmap (have a hashmap generated out of it):

# postmap hash:/etc/postfix/virtual_maps

On the Cyrus IMAP side, we must first check that the daemon listens on the proper lmtp socket (by default it should):

# cat /etc/cyrus.conf | grep lmtp
lmtpunix	cmd="lmtpd" listen="/var/lib/imap/socket/lmtp" prefork=1

NB: at this point one may want to disable SELinux in order to allow for the socket communication between postfix and Cyrus IMAP.

Continue Reading →