Postfix Virtual Hosting With LDAP Backend And With Dovecot As IMAP/POP3 Server On Ubuntu Kamic Koala 9.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=phamm,o=hosting,dc=example,dc=tld #==>Change this and below if needed
password readonly
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/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 'admin' 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.

Next steps are the optional Roundcube and proftpd configuration.

Share this page:

7 Comment(s)

Add comment


From: Zabidin at: 2009-12-30 06:44:01


 I stuck at this part.


ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/cosine.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/inetorgperson.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/nis.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/phamm.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/ISPEnv2.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/amavis.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/pureftpd.ldif
ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/perversia.ldif 

 It said about permission. I don't know which permission. I install as root, should be no problem.

From: Anonymous at: 2009-12-15 21:28:46

Several months ago I followed a similar guide on 9.1

I have been upgrading since but lacked the ability for users to change their own passwords.   Phamm 5.15 issue permissions issue.


I'm thinking about trying to do an in place upgrade on a very busy mail server.   

 Are there any "gotcha's" to lookout for when I Try to upgrade the schema?

Is this even possible?

From: Matteo at: 2011-03-17 21:01:29

server:/etc/ldap/slapd.d/cn=config/cn=schema# ldapadd -Y EXTERNAL -H ldapi:// -f /etc/ldap/schema/db.ldif
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
adding new entry "cn=module{0},cn=config"
ldap_add: Naming violation (64)

From: Alexandre Moraes at: 2010-08-27 16:51:13

Trouble with maildrop:

(user unknown. Command output: ERR: authdaemon: s_connect() failed: No such file or directory Invalid user specified. )


touch /etc/postfix/maildroprc and add:


vim /etc/postfix/ and modify:

maildrop  unix  -       n       n       -       -       pipe

   flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}


maildrop  unix  -       n       n       -       -       pipe

  flags=DRhu user=vmail argv=/usr/bin/maildrop /etc/postfix/maildroprc ${nexthop} ${recipient}

From: Dominik at: 2011-03-24 09:43:11

I had the same error message, but, I don't want to use maildrop, I prefere dovecot. my problem was the postfixTransport attribute on the virtual domain. I forgot to change the plugins/mail.xml of phamm, so every new domain had maildrop in the postfixTransport attribute of the ldap. with phpldapadmin, navigate to hosting, select view childs, as table, select all, edit, paste dovecot: into the postfixTransport attribute and update all. Cheers Dominik

From: kewlrichie at: 2009-12-21 17:33:32

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: Pavel Sebek at: 2010-06-24 08:20:50


i would like correct a mistake in guide:



 the file main.php:


Change (line 308):

$entry["maildrop"] = "postmaster";


$entry["mail"] = "dummy@".$domain_new;




the file main.php:


Change (line 308):

$entry["maildrop"] = "postmaster";


$entry["maildrop"] = "dummy@".$domain_new;