How I Installed Postfix, Dovecot and Roundcube on my Bitnami LAMP Stack

In addition to my previous article about installing PostfixAdmin, I am now summing up my findings that I picked up along the way of installing Postfix, Dovecot and and Roundcube on my Bitnami LAMP stack.

To get it all working I had to go over a dozen of articles and tutorials, and a few days and some headaches later I was finally able to send and receive mail, although there are still some trust related challenges to overcome.

First and foremost, if you have followed some sort of tutorial, and haven’t got it working, I suggest you start from scratch. But even removing Postfix and Dovecot can be troublesome.

How to remove APT packages completely

When I was trying to remove and reinstall Dovecot I got the following kind of error messages:

Not replacing deleted config file /etc/dovecot/dovecot.conf

What ever I tried, they didn’t stop showing up on a new install. But eventually I found the trick, which is this sequence:

sudo apt-get remove dovecot-core dovecot-imapd
sudo dpkg -P dovecot-core
sudo dpkg -P dovecot-imapd
sudo rm -rf /etc/dovecot
sudo rm -rf /var/lib/dovecot
sudo apt-get --purge autoremove
sudo apt-get --purge autoclean

Then finally reinstalling with the following command:

sudo apt-get install dovecot-core dovecot-imapd

You will see the following kind of messages when it finally works:

Creating config file /etc/dovecot/dovecot.conf with new version

Installing Postfix

Basically, there is not much to it, however the configuration of Postfix is where the finetuning goes. First of all execute the following command to install it:

sudo apt-get install postfix
sudo postconf -e 'smtpd_sasl_local_domain ='
sudo postconf -e 'smtpd_sasl_auth_enable = yes'
sudo postconf -e 'smtpd_sasl_security_options = noanonymous'
sudo postconf -e 'broken_sasl_auth_clients = yes'
sudo postconf -e 'smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination'
sudo postconf -e 'inet_interfaces = all'
sudo postconf -e 'smtp_tls_security_level = may'
sudo postconf -e 'smtpd_tls_security_level = may'
sudo postconf -e 'smtpd_tls_auth_only = no'
sudo postconf -e 'smtp_tls_note_starttls_offer = yes'
sudo postconf -e 'smtpd_tls_key_file = /opt/bitnami/apache2/conf/server.key'
sudo postconf -e 'smtpd_tls_cert_file = /opt/bitnami/apache2/conf/server.crt'
sudo postconf -e 'smtpd_tls_CAfile = /etc/ssl/certs/ca-certificates.crt'
sudo postconf -e 'smtpd_tls_loglevel = 1'
sudo postconf -e 'smtpd_tls_received_header = yes'
sudo postconf -e 'smtpd_tls_session_cache_timeout = 3600s'
sudo postconf -e 'tls_random_source = dev:/dev/urandom'
sudo postconf -e 'myhostname = yourdomain.com'

How to install JavaScript dependencies for Roundcube

First of all go to the Roundcube installation folder. If you did it the proper way you have installed Roundcube inside the /opt/bitnami/apps/ folder. After you have cd’ed into it, execute the following command to install all Roundcube JavaScript dependencies:

cd /opt/bitnami/apps/roundcube
sudo bin/install-jsdeps.sh