Drupal + Postfix Integration Under Ubuntu 8.04 (Hardy)

Version: 1.02
Author: Alex Saavedra
Last Update: October 9, 2008
License: © 2008 Alex Saavedra. This document is published under the terms of the GNU General Public License (http://www.gnu.org/licenses/gnu.html).

This document is derived from Christoph Haas’ tutorial “Howto: ISP-style Email Server with Debian-Etch and Postfix” (http://workaround.org) and Falko Timme’s tutorial “Virtual Users And Domains With Postfix, Courier, MySQL And SquirrelMail (Ubuntu 8.04 LTS)” (http://www.howtoforge.com). The associated Mailfix Drupal module must be installed as part of this tutorial.

It will guide you through the necessary steps to configure a Drupal driven Mail server. Provided features:

  • Drupal managed email accounts
  • Support for virtual domains
  • Automatic forwarding
  • Postfix quota support
  • Silent BCC monitoring
  • Other features: anti-spam, anti-virus



This tutorial is the result of many attempts to replace a couple of Postfix mail servers which were maintained with text files. Every time I had to create or drop an account I was required to vi those files, then reload the Postfix configuration. Same thing when users went on vacation (automatic forwarding) or supervisors asked for BCC monitoring. Yep, not funny.

Then Drupal was introduced to our corporate environment to manage our Intranet. The result was a total success. I thought how great it could be if we could manage our mail users from this same location.

So I went through such superb works from Christoph Haas (http://workaround.org/articles/ispmail-etch/) and Falko Timme (http://www.howtoforge.com/virtual-users-domains-postfix-courier-mysql-squirrelmail-ubuntu8.04).

Then I found a great Drupal module from Thomas Barregren (http://drupal.org/project/mailserver) which had almost all the functionality we required, and was based on Christoph Haas’ work for the Postfix/MySQL integration. We thoroughly tested and reviewed this module for a couple of weeks. Unfortunately we still had to maintain the mail quota, forwarding and BCC monitoring part by hand.
Inspired by such awesome work, we finally decided to write a Drupal 6 module in order to keep all things in one place.

This is how this tutorial and its associated Drupal Mailfix module came to life.


Preliminary Tasks

First of all you need to install Linux on your target machine. We installed Linux Ubuntu 8.04 Server.

Select the following software packages:

  • OpenSSH server

Ensure that your IP will always be the same (fixed IP, or DHCP + IP reservation).
Write down your installation credentials:

Credentials Sample Settings

user: someuser
password: opensesame


user: root@localhost
password: opensesame

Drupal database: drupal_example_com
user: drupal_example_com@localhost
password: opensesame

Drupal user: admin
password: opensesame

Once your system makes a fresh boot to the newly installed OS, all tasks will require root privileges. Thus you should start a root session right away:

sudo -i

Share this page:

6 Comment(s)

Add comment


From: MarkFoodyBurton at: 2009-01-21 12:17:13

Not sure the quota stuff will work

1. the postfix config param seems to be virtual_mailbox_limit, not virtual_mailbox_limit_map as mentioned here.

2. I suspect  that since Dovecot is being used for delivery, the number will be ignored anyway?

 Hope I'm wrong :-)






From: vivek at: 2011-06-02 10:26:13

In the mysql query from where does the place holder is getting the values. I am new to this world please help

From: Paul H at: 2008-10-28 18:25:36

It appears that dovecot expects a returned field called 'password' whilst the mysql and drupal returns a field called 'pass' which means that authentications via pop3 and imap don't work.

Any thoughts?


From: Nik Sulaiman at: 2008-11-18 03:11:04

in /etc/dovecot/dovecot-sql.conf

add the underlined text:

password_query = SELECT mail AS user, pass AS password FROM users WHERE mail='%u';

I was having the problem too, thanks for the post.

Managed to authenticate via imap successfully. Hope it helps.

From: at: 2009-03-06 21:29:14

Nik Sulaiman,

 Thank you for your fix. It has been updated in the tutorial.

 Alex Saavedra

From: plen at: 2011-01-29 07:57:53

The mail_plugins line in the dovecot.conf should be set to just "sieve" not "cmusieve"