Postfix Virtual Hosting With LDAP Backend And With Dovecot As IMAP/POP3 Server On Ubuntu Intrepid Ibex Server 8.10 - Page 5

Step 6: Install And Configure gnarwl

Let's install gnarwl:

apt-get install gnarwl

Now let's configure gnarwl.

First we're going to back up the original configuration file and replace it with a new one.

mv /etc/gnarwl.conf /etc/gnarwl.conf.bck

Now we create the new conf file:

vi /etc/gnarwl.conf

And insert the following:

map_sender $sender
map_receiver $recepient
map_subject $subject
map_field $begin vacationStart
map_field $end vacationEnd
map_field $fullname cn
map_field $deputy vacationForward
map_field $reply mail
server localhost
port 389
scope sub
login cn=admin,dc=example,dc=tld
password secret
protocol 0
base dc=example,dc=tld
queryfilter (&(mailAutoreply=$recepient)(vacationActive=TRUE))
result vacationInfo
blockfiles /var/lib/gnarwl/block/
umask 0644
blockexpire 48
mta /usr/sbin/sendmail -F $recepient -t $sender
maxreceivers 64
maxheader 512
charset ISO8859-1
badheaders /var/lib/gnarwl/badheaders.db
blacklist /var/lib/gnarwl/blacklist.db
forceheader /var/lib/gnarwl/header.txt
forcefooter /var/lib/gnarwl/footer.txt
recvheader To Cc
loglevel 3

Change the default to your actual configuration.

Last but not least execute the following command to make gnarwl work:

chown -R vmail:vmail /var/lib/gnarwl/

This concludes the gnarwl configuration. 


Step 7: Bringing It All Together And Making It Work

The following command will put into effect the configurations we made before:

/etc/init.d/apache2 stop
/etc/init.d/apache2 start
/etc/init.d/dovecot stop

First we restart postfix:

/etc/init.d/postfix start

We need to do this in order to have the following directory created:


Now we need to make new ssl certificates for Dovecot:

dpkg-reconfigure dovecot-common

If the directory /var/run/dovecot and /var/run/dovecot/login don't exist the reconfigure command above will produce errors complaining that the directories do not exist. In that case just create them. And re-run the command above.

Now we can start Dovecot:

/etc/init.d/dovecot start

You can now browse to http://example.tld/phamm

Log in with the user admin and your OpenLDAP password.

You should now be able to create domains and users.

One more thing: since phamm doesn't actually delete users and / or domains, we need to enable the that comes with phamm.

cp /var/www/tools/ /home/vmail/.

Edit the file to your settings, but set the  BINDDN to BINDDN="cn=admin,dc=example,dc=tld" for the script to work correctly.

Now we add a crontab to run the script periodically:

crontab -e

And insert the following:

30 * * * * /home/vmail/

Well everything should be up and running now.

Share this page:

13 Comment(s)

Add comment


From: ronw at: 2009-02-11 15:30:43

When I run the ldapmodify command with the acl-del.ldif file I get the following message:

ldapmodify: wrong attributeType at line 3, entry "olcDatabase={1}hdb,cn=config"

What did I miss?

From: at: 2009-03-22 23:23:48

Hi, here is a thread to talk about the ACL problem:

From: ww at: 2009-02-26 02:28:01

I am encountering the same error as ronw:

When I run the ldapmodify command with the acl-del.ldif file I get the following message:

ldapmodify: wrong attributeType at line 3, entry "olcDatabase={1}hdb,cn=config"

What did I miss?

From: MyTer at: 2009-02-06 14:00:12

Hi hoihtah

I got the same outcome, but I moved ldif_out to be under


and also placed schema.convert there,

that did the trick!


From: at: 2009-01-24 19:28:14

Beautifull, simply outstanding. Thank you very much.


From: at: 2009-01-26 23:31:50

I'm getting no such file or directory error after

 cp phamm-0.5.15/schema/phamm.schema .

 which directory should I be in when i run that command?

From: Pietro at: 2009-03-02 09:12:37

Argh... the same to me...

Conf: ubuntu server8.10 just apt-get updated and upgraded...

From: Anonymous at: 2009-05-21 19:38:20

same here ... don;t know how to get through it :( ...

From: Alex at: 2009-07-30 19:18:34

To fix this issue, simply delete the lines manually from the olcDatabase={1}hdb.ldif file...

vi /etc/ldap/slapd.d/cn\=config/olcDatabase\=\{1\}hdb.ldif

From: P. Larsen at: 2009-09-11 00:15:02

Thanks for your guide - it's been helpful getting me to understand phamm better.

I wish you could clarify a few areas of why you choose to do what you did. First of all, how/where do you bind phamm into the mail delivery process so anti-virus and spam filters can be applied or not, depending on the user's configuration option?

What's the advantage of using dovecot as a delivery method?

From: rich at: 2009-04-30 20:38:42

when editing the there seems to be a typo that really had me stuck for a while and it would like to point it out. Notice at the end of the string where is says {recipient)

it should read {recipient} they both should have curly braces not a parenthesis at the end

This is the right string below

dovecot   unix  -       n       n       -       -       pipe
     flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${recipient}

From: rich at: 2009-04-30 20:49:40

If you want your mail to end up in /home/vmail/domains so the full path of an email mailbox looks like this /home/vmail/domains/example.tld/bob@example.tld, which phamm and ldap is expecting it to be, you would need to change.

mail_location = maildir:/home/vmail/%d/%u


mail_location = maildir:/home/vmail/domains/%d/%u



From: Anonymous at: 2009-03-09 14:20:13

hi there, great work on this howto.

there's some work that isn't entirely explicit, which is mostly fine, except for security holes.  since you configure various things to use the rootdn, those configuration files should be unreadable.

# chmod o-rwx /etc/postfix/ (readable by all by default)

# chmod o-rwx /etc/dovecot/dovecot-ldap.conf (secure by default in ubuntu intrepid, but good practice to check)

# chmod o-rwx /etc/gnarwl.cfg (readable by all by default)