View Single Post
  #1  
Old 20th May 2010, 01:34
radim_h radim_h is offline
Senior Member
 
Join Date: Jan 2007
Location: Prague, Czech
Posts: 424
Thanks: 34
Thanked 26 Times in 21 Posts
Send a message via ICQ to radim_h
Default HOWTO: Dovecot 1.2.9 + sieve + quota

Hello,

i spent couple hours tampering with dovecot 1.2.9 on Ubuntu 10.04, now it finally works, so maybe someone can use it... it will be probalby same for Debian Squeeze

First, here is my /etc/dovecot/dovecot.conf file:

Code:
base_dir = /var/run/dovecot/

protocols = imap imaps pop3 pop3
disable_plaintext_auth = no
log_timestamp = "%Y-%m-%d %H:%M:%S "

ssl_cert_file = /etc/ssl/_.my-domain.tld/_.my-domain.tld.crt
ssl_key_file = /etc/ssl/_.my-domain.tld/_.my-domain.tld.key

mail_privileged_group = mail

login_greeting = my-domain.tld IMAP server ready...

## IMAP specific settings
protocol imap {
mail_executable = /usr/lib/dovecot/rawlog /usr/lib/dovecot/imap
  mail_plugins = quota imap_quota
}

## POP3 specific settings
protocol pop3 {
  mail_executable = /usr/lib/dovecot/rawlog /usr/lib/dovecot/pop3
  pop3_uidl_format = %08Xu%08Xv
  mail_plugins = quota
}

## LDA specific settings
protocol lda {
  # Address to use when sending rejection mails.
  postmaster_address = postmaster@my-domain.tld

  # Support for dynamically loadable plugins. mail_plugins is a space separated
  # list of plugins to load.
  mail_plugin_dir = /usr/lib/dovecot/modules/lda


  # UNIX socket path to master authentication server to find users.
  auth_socket_path = /var/run/dovecot/auth-master

  # Enabling Sieve plugin for server-side mail filtering
  mail_plugins = sieve quota
}


## Plugin settings
plugin {
        quota = maildir
        sieve=/var/vmail/%d/%n/.sieve
}


## Authentication processes

# Executable location
#auth_executable = /usr/lib/dovecot/dovecot-auth
auth default {
  mechanisms = plain login
  passdb pam {
  }

  # SQL database <doc/wiki/AuthDatabase.SQL.txt>
  passdb sql {
    # Path for SQL configuration file
    args = /etc/dovecot/dovecot-sql.conf
  }

# new quota support:
        userdb prefetch {
                }

        userdb sql {
                args = /etc/dovecot/dovecot-sql.conf
                }


  ## dovecot-lda specific settings
  ##
  socket listen {
    master {
      path = /var/run/dovecot/auth-master
      mode = 0600
      user = vmail # User running Dovecot LDA
      #group = vmail # Or alternatively mode 0660 + LDA user in this group
    }
  client {
          path = /var/spool/postfix/private/auth
          mode = 0660
          user = postfix
          group = postfix
        }
  }

}

mail_location = maildir:/var/vmail/%d/%n/Maildir

mail_uid = 5000
mail_gid = 5000
As you can have noticed all the users will have uid& gid 5000, also sieve script location & maildir will be following same pattern , so we don't have to read this data from MySQL all the time.

This is the original user query:
user_query = SELECT email as user, maildir as home, CONCAT(maildir, '/Maildir') as mail, uid, gid, CONCAT('maildir:storage', quota) AS quota, CONCAT(maildir, '/.sieve') AS sieve FROM mail_user WHERE email = '%u' AND disable%Ls = 'n']

I have removed uid, gid, sieve and also "user_query = CONCAT(maildir, '/Maildir')" as is doen't seem to be used anywhere


Now we can modify
/etc/dovecot/dovecot-sql.conf
Code:
driver = mysql
connect = host=localhost dbname=dbispconfig user=ispconfig password=your_gerated_password_from_ISPC3
default_pass_scheme = CRYPT
password_query = SELECT password FROM mail_user WHERE email = '%u' AND disable%Ls = 'n'

### we must change user query, here is the correct one, notice that storage quota must be set in bytes
user_query = SELECT email AS user, maildir AS home, CONCAT('*:storage=', quota , 'B') AS quota_rule FROM mail_user WHERE email = '%u' AND disable%Ls = 'n'
That's it. Sieve scripts are working , roundcube is showing correct quota, also Thunderbird.

Last edited by radim_h; 20th May 2010 at 01:41.
Reply With Quote
Sponsored Links