How To Install & Set Up Dovecot Mail Server With Sieve And Virtual Users
How To Install & Set Up Dovecot Mail Server With Sieve And Virtual UsersThis document describes how to install the Dovecot mail server from source as an imap / pop3 mail server for your domain and how to set up the sieve plugin so your clients can use the sieve mail filtering language for their mail accounts.
1. Get the SourcesWe can download Dovecot from http://dovecot.org. I always prefer stable versions so: wget -c http://dovecot.org/releases/1.0/dovecot-1.0.13.tar.gz We also need the sieve plugin source so: wget -c http://dovecot.org/releases/sieve/dovecot-sieve-1.0.2.tar.gz
2. Install DovecotAt this point we can continue with the installation of dovecot mail server tar zxfv dovecot-1.0.13.tar.gz And now we need to install the sieve plugin tar zxfv dovecot-sieve-1.0.2.tar.gz
3. ConfigurationThe basic configuration file of dovecot is /usr/local/etc/dovecot.conf and we can create it by doing this: cp -pi /usr/local/etc/dovecot-example.conf /usr/local/etc/dovecot.conf The main configuration of dovecot is here : http://wiki.dovecot.org/MainConfig The below config is a basic configuration file for these features: Imap Protocol, Local Delivery Agent with Sieve plugin, Virtual Users from file and support other programs to authenticate with the dovecot mail server. # Dovecot configuration file
base_dir=/usr/local/var/run/
protocols = imap
listen = *:143
# We can use plain text passwords
disable_plaintext_auth = no
# Logging
log_path = /var/log/dovecot.log
info_log_path = /var/log/dovecot.info.log
log_timestamp = "%b %d %H:%M:%S "
# SSL settings
# Without ssl
ssl_disable = yes
# Login processes
login_user = dovecot
login_greeting = Hi buddy, have an account ?
login_log_format = %$: %s
# Mailbox locations and namespaces
mail_extra_groups = mail
# Mailbox locations and namespaces
# Clients Inbox at /var/mail, Clients Folders at /var/mail/folders/username/
mail_location = mbox:/var/mail/folders/%u/:INBOX=/var/mail/%u
# Mail processes
mail_debug = yes
mail_log_prefix = "%Us(%u): "
verbose_proctitle = yes
first_valid_uid = 1000
last_valid_uid = 5000
max_mail_processes = 2048
# mbox-specific settings
mbox_read_locks = dotlock fcntl
mbox_write_locks = dotlock fcntl
# IMAP specific settings
protocol imap {
}
# LDA specific settings
protocol lda {
postmaster_address = root@mydomain.org
hostname = mydomain.org
# Sieve plugin for local delivery agent
mail_plugins = cmusieve
log_path = /var/log/dovecot-local-deliver.log
auth_socket_path = /usr/local/var/run/dovecot-auth-master
}
# Authentication processes
auth_verbose = yes
auth_debug = yes
auth_debug_passwords = yes
auth default {
mechanisms = plain
passdb passwd-file {
# Virtual Users from file
args = /usr/local/etc/dovecot.passdb
}
userdb passwd-file {
# Virtual Users from file
args = /usr/local/etc/dovecot.passdb
}
user = root
# It's possible to export the authentication interface to other programs:
# For example getmail with MDA external
socket listen {
master {
path = /usr/local/var/run/dovecot-auth-master
mode = 0660
user = dovecot
group = mail
}
}
}
We need to create the configuration file that dovecot reads to authenticate virtual users, /usr/local/etc/dovecot.passdb user1:{PLAIN}pass1:1001:1001:User 1 Name:/var/mail/folders/user1:: mail_plugins=cmusieve
user2:{PLAIN}pass2:1002:1002:User 2 Name:/var/mail/folders/user2:: mail_plugins=cmusieve
user3:{PLAIN}pass3:1003:1003:User 3 Name:/var/mail/folders/user3:: mail_plugins=cmusieve
user4:{PLAIN}pass4:1004:1004:User 4 Name:/var/mail/folders/user4:: mail_plugins=cmusieve
Now we are ready to test our imap mail server.
4. Begin & Test DovecotTo start the dovecot mail server just type: /usr/local/sbin/dovecot ps -ef | grep dovecot If there are any problems just see the log files. tail -f /usr/local/dovecot* To verify the config of running dovecot: /usr/local/sbin/dovecot -n # 1.0.13: /usr/local/etc/dovecot.conf
base_dir: /usr/local/var/run/
log_path: /var/log/dovecot.log
info_log_path: /var/log/dovecot.info.log
protocols: imap
listen: *:143
ssl_disable: yes
disable_plaintext_auth: no
login_dir: /usr/local/var/run//login
login_executable: /usr/local/libexec/dovecot/imap-login
login_greeting: Hi buddy, have an account ?
max_mail_processes: 2048
verbose_proctitle: yes
first_valid_uid: 1000
last_valid_uid: 5000
mail_extra_groups: mail
mail_location: mbox:/var/mail/folders/%u/:INBOX=/var/mail/%u
mail_debug: yes
mbox_read_locks: dotlock fcntl
auth default:
verbose: yes
debug: yes
debug_passwords: yes
passdb:
driver: passwd-file
args: /usr/local/etc/dovecot.passdb
userdb:
driver: passwd-file
args: /usr/local/etc/dovecot.passdb
socket:
type: listen
master:
path: /usr/local/var/run/dovecot-auth-master
mode: 432
user: dovecot
group: mail
If everything till now are running ok, you should check the mail server via telnet. To do this just type the below: # telnet localhost 143 1 login username password If you use the above dovecot.conf then you should test it like this: # telnet mydomain.org 143 1 login user1 pass1 And to check the INBOX: # telnet mydomain.org 143 * OK Hi buddy, have an account ? And if you want to check that it finds other mailboxes: # telnet mydomain.org 143 * OK Hi buddy, have an account ?
5. Use SieveThe Sieve is a Mail Filtering Language and you can find everything here: http://tools.ietf.org/html/rfc3028. Dovecot plugin reads the .dovecot.sieve file from our mail location. The above dovecot.conf sets the mail location at /var/mail/folders/usename. So you need to create the file: touch /var/mail/folders/user1/.dovecot.sieve According to rfc you can write your rules. An example is here: require "fileinto";
if header :comparator "i;ascii-casemap" :contains "Subject" "**SPAM**" {
fileinto "Trash";
stop;
}
This sieve rule delivers every email where the header subject contains "**SPAM**" to the Trash folder. If you want to validate your sieve rules here is the perfect project:http://libsieve-php.sourceforge.net/. If you have apache installed you can set up web mail clients like Horde Groupware Webmail Edition or IlohaMail. 6. Usefull Links
|



Recent comments
9 hours 35 min ago
14 hours 40 min ago
19 hours 4 min ago
20 hours 53 min ago
1 day 11 hours ago
1 day 11 hours ago
1 day 16 hours ago
1 day 22 hours ago
1 day 23 hours ago
2 days 51 min ago