Postfix Virtual Hosting With LDAP Backend And With Dovecot As IMAP/POP3 Server On Ubuntu Kamic Koala 9.10 - Page 3

Step 4: Install And Configure Dovecot

aptitude install dovecot-imapd dovecot-pop3d

This will install dovecot and all necessary files and also create the standard ssl certificates for IMAPs and POP3s.

Now we back up the original configuration file for safe keeping.

mv /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.bck
mv /etc/dovecot/dovecot-ldap.conf /etc/dovecot/dovecot-ldap.conf.bck

Next you can create new configuration files with the examples provided below.

vi /etc/dovecot/dovecot.conf

auth_verbose = yes
mail_debug = no

base_dir = /var/run/dovecot/
protocols = imap imaps pop3 pop3s
protocol imap {
        mail_plugins = quota imap_quota
        imap_client_workarounds = outlook-idle

protocol pop3 {
        mail_plugins = quota
        pop3_no_flag_updates = yes
        pop3_reuse_xuidl = no
        pop3_lock_session = no
        pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
protocol lda {
  mail_plugins = quota
  postmaster_address = postmaster@example.tld
  auth_socket_path = /var/run/dovecot/auth-master
plugin {
        quota = maildir
        quota_rule = Trash:storage=10%%
        quota_rule2 = Spam:storage=10%%
        quota_warning = storage=95%%/home/vmail/bin/ 95
        quota_warning2 = storage=80%% /home/vmail/bin/ 80
listen = *
shutdown_clients = yes
log_timestamp = "%b %d %H:%M:%S "
syslog_facility = mail
disable_plaintext_auth = no
ssl_disable = no
ssl_cert_file = /etc/ssl/certs/mail.example.tld.pem #==> Change this and below to the neame you want
ssl_key_file = /etc/ssl/certs/mail.example.tld.pem
login_chroot = yes
login_user = postfix
login_process_per_connection = yes
login_processes_count = 2
login_max_processes_count = 128
login_max_connections = 256
login_greeting = Welcome to Dovecot eMail Server.
login_log_format_elements = user=<%u> method=%m rip=%r lip=%l %c
login_log_format = %$: %s
#default_mail_env = maildir:/home/vmail/%d/%u
mail_location = maildir:/home/vmail/%d/%u
first_valid_uid = 108 # REMEBER THIS MUST BE CHANGED TO YOUR UID FOR "postfix" FROM /etc/passwd
mail_uid = 1000
mail_gid = 1000
pop3_uidl_format = %08Xu%08Xv
auth default {
    mechanisms = PLAIN LOGIN
    passdb ldap {
        args = /etc/dovecot/dovecot-ldap.conf
    userdb ldap {
        args = /etc/dovecot/dovecot-ldap.conf
socket listen {
                master {
                        path = /var/run/dovecot/auth-master
                                mode = 0600
                        user = vmail
                        group = vmail
                client {
                        path = /var/spool/postfix/private/auth
                        mode = 0660
                        user = postfix
                        group = postfix
        user = vmail

vi /etc/dovecot/dovecot-ldap.conf

hosts = localhost
auth_bind = yes
auth_bind_userdn = mail=%u,vd=%d,o=hosting,dc=example,dc=tld
ldap_version = 3
base = o=hosting,dc=example,dc=tld
dn = cn=phamm,o=hosting,dc=example,dc=tls #The readonly user
dnpass = the readonly password
deref = never
scope = subtree
user_attrs = quota=quota=maildir:storage
user_filter = (&(objectClass=VirtualMailAccount)(accountActive=TRUE)(mail=%u))
pass_attrs = mail,userPassword
pass_filter = (&(objectClass=VirtualMailAccount)(accountActive=TRUE)(mail=%u))
default_pass_scheme = MD5
user_attrs = quota=quota=maildir:storage=%$B

Note: Remember to change example.tld to your own domain.tld (see assumptions).

Quota support is enabled, but no quota warnings are issued. This can be done with a script file that issues the quota warnings.

Now we need to create the

vi /usr/local/bin/

And paste the following into it:

cat << EOF | /usr/local/libexec/dovecot/deliver -d $USER -c /etc/dovecot/dovecot-nowarning.conf
Subject: quota warning

Your mailbox is now $PERCENT% full.

Now me make the script executable:

chmod +x /usr/local/bin/

The dovecot-nowarning.conf is a copy from your dovecot.conf file from which the % warning lines are removed.

So we copy the dovecot.conf file:

cp /etc/dovecot/dovecto.conf /etc/dovecto/dovecot-nowarning.conf

We edit this files and remove the lines below.

nano /etc/dovecto/dovecot-nowarning.conf

quota_warning = storage=95%%/home/vmail/bin/ 95
quota_warning2 = storage=80%% /home/vmail/bin/ 80

The lines below specify the amount of space (from the quota) that is assigned to the Trash and Spam folder.

quota_rule = Trash:storage=10%%
quota_rule2 = Spam:storage=10%%

This configuration uses 10 of the total quota for the mailbox respectively for the Trash and Spam folder. So with a quota of 100Mbyte a user is limited to 80Mbyte for emails, 10Mbyte for the Trash folder and 10Mbyte for the Spam folder.

This concludes the Dovecot 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;