I had this requirement for deploying an email system with IMAP. I already had a bit of experience with postfix and cyrus IMAP. But I wanted something different this time. So I started searching for a server which was capable of working with sendmail. Sendmail was already running on the server I was working on and I was not keen on installing another SMTP server from scratch (lazy me). The server OS was Red Hat Linux. After some research I came across Dovecot.
Sendmail is a general purpose internetwork email routing facility that supports many kinds of mail-transfer and -delivery methods, including the Simple Mail Transfer Protocol (SMTP) used for email transport over the Internet.
Dovecot is an open source IMAP and POP3 server for Linux/UNIX-like systems, written primarily with security in mind. Developed by Timo Sirainen, Dovecot was first released in July 2002. Dovecot primarily aims to be a lightweight, fast and easy to set up open source mailserver.
Dovecot can work with standard mbox, Maildir, and its own experimental native high-performance dbox formats. It is fully compatible with UW IMAP and Courier IMAP servers’ implementation of them, as well as mail clients accessing the mailboxes directly. Dovecot also includes a Mail delivery agent (called Local delivery agent in Dovecot’s documentation), with optional Sieve filtering support.
Ok now to the technical part
What do we need?
Sendmail – Already installed with Red Hat. If not can get from http://www.sendmail.org/
Dovecot – We can download Dovecot from http://dovecot.org. I always prefer stable versions.
Name server (DNS) – I assume a name server has already been setup or is available. I will be adding an article on `named` the linux DNS server I use later on.
Installing Dovecot
Once the dovecot sources are downloaded (the version I used is 1.2.10) to the server, we can continue with the installation of dovecot mail server as follows,
# cd /usr/software
# tar -zxf dovecot-1.2.10.tar.gz
# cd dovecot-1.2.10
# ./configure
# make
# make install
Now we need to install the sieve plugin:
# cd /usr/software
# tar -zxf dovecot-sieve- 1.1.8.tar.gz
# cd dovecot-sieve- 1.1.8
# ./configure –with-dovecot=../dovecot-1.2.10
# make
# make install
Dovecot Configuration
The basic configuration file of dovecot should be in /usr/local/etc/dovecot.conf and we can create it by doing the following step.
# cp dovecot-example.conf /usr/local/etc/dovecot.conf
A description of the main configuration of dovecot is here: http://wiki.dovecot.org/MainConfig
The below is a basic configuration file for these features: IMAP Protocol, Virtual Users from password storage file (authentication file) and support other programs to authenticate with the dovecot mail server.
#Base directory where to store runtime data.
base_dir=/usr/local/var/run/
# protocols = imap pop3
protocols = imap 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
ssl = no
# Login processes
login_dir =/var/run/dovecot/login login_chroot = yes login_user = dovecot login_greeting = 'Hi buddy, have an account ?' login_log_format = %$: %s
# Mailbox locations and namespaces
mail_privileged_group = mail
# Mailbox locations and namespaces
mail_location = mbox:/var/mail/folders/%u/:INBOX=/var/mail/%u:INDEX=/var/mail/index/%u
# Mail processes
max_mail_processes = 2048 mail_debug = yes mail_log_prefix = "%Us(%u): " verbose_proctitle = yes first_valid_uid = 1000 last_valid_uid = 5000
# Mail Optimaze
max_mail_processes = 512 mailbox_idle_check_interval = 30
# mbox-specific settings
mbox_read_locks = dotlock fcntl mbox_write_locks = dotlock fcntl
# IMAP specific settings
protocol imap {
listen = *:143 mail_plugins = autocreate imap_client_workarounds = tb-extra-mailbox-sep
}
plugin {
autocreate = Drafts autocreate2 = Sent autocreate3 = Trash autosubscribe = Drafts autosubscribe2 = Sent autosubscribe3 = Trash
}
# LDA specific settings
protocol lda {
postmaster_address = shamly1 hostname = mydomain.org 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
# Authentication Cache
auth_cache_size = 10240 auth_cache_ttl = 18000
auth default {
mechanisms = plain
passdb passwd-file {
args = /usr/local/etc/dovecot.passdb
}
userdb passwd-file {
args = /usr/local/etc/dovecot.passdb
}
user = root
# It's possible to export the authentication interface to other programs:
socket listen {
master {
path = /usr/local/var/run/dovecot-auth-master mode = 0660 user = dovecot group = mail
}
}
}
# plugin
plugin {
sieve = /var/mail/folders/%u/.dovecot.sieve
}
Next we need to create the dovecot.passdb the authentication file located in /usr/local/etc directory as specified in the dovecot.conf file.
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
dovecot user is used internally for processing users’ logins. It shouldn’t have access to any files, authentication databases or anything else either. It should belong to its own private dovecot group where no one else belongs to, and which doesn’t have access to any files either (other than what Dovecot internally creates).
Dovecot Mail users
You can use one or more system users for accessing users’ mails. Most configurations can be placed to two categories:
- System users where each Dovecot user has their own system user in /etc/passwd. For system user setups you generally don’t have to worry about UIDs or GIDs.
- Virtual users where all Dovecot users run under a single system user, for example vmail (just NOT dovecot).
However it’s possible to use a setup that is anything between these two. For example use a separate system user for each domain. In my example configuration I am using the second option.
Now let’s try to run the dovecot server
To verify the config of running dovecot:
# /usr/local/sbin/dovecot –n
To start the dovecot mail server just type:
# dovecot
To check all running process by the user dovecot, do
# ps aux | grep dovecot
If there are any problems just see the log files:
# tail -f /var/log/dovecot.log
If everything till now is running ok, you should check the mail server via telnet. To do this just type the below command:
# telnet localhost 143
Trying 127.0.0.1…
Connected to localhost.
Escape character is ‘^]’.
* OK [CAPABILITY IMAP4rev1 SORT THREAD=REFERENCES MULTIAPPEND UNSELECT
LITERAL+ IDLE CHILDREN NAMESPACE LOGIN-REFERRALS AUTH=PLAIN] Dovecot ready.
1 login test test
1 OK Logged in.
Wow .. now we have our dovecot server up and running. In the next part I will run through the steps on how to setup the sendmail server.
Possibly Related Posts:



Good brief and this helped me a lot in my college assignment. Thanks you on your information. Hope you publish part – 2 of this in the near future.
genericwpthemes
omg … so here’s how brainless I am, midway through looking through your post I accidentally dropped my cup of coffee on my desk and shut the site by accident. I could not locate your web page again until 4 days afterwords to finish reading from the spot i had left off due to the fact I did not remember how I linked to your blog in the first place. In any case it was worth the hold out … kudos
My Profile
Great post. Hope to see even more excellent posts in the near future.
Took me time to read all the comments, but I really loved the article. It proved to be Very helpful to me.
Hey, very nice website. I actually came across this on Yahoo, and I am really happy I did. I will definately be returning here more often. Wish I could add to the conversation and bring a bit more to the table, but am just absorbing as much info as I can at the moment.
Thank You
watch movies online for free
Wonderful insight
Well dome mate!
You’re a Really Professional Blogger, You either have got quality knowledge of what your discussing or you did some great research. Thanks for this excellent post.
Great blog post. Really looking forward to read more.
Hmmm…very good to find out, there have been without a doubt a number of elements that I had not idea of before.
Great blog post. Really looking forward to read more.
oh cool, this information is really useful and definately is comment worthy! hehe. I’ll see if I can try to use some of this information for my own blog. Thanks!
Please let me know if you’re looking for a writer for your blog. You have some good content and I think I would be a good asset.
Well, the article is really the greatest on this valuable topic. I agree with your conclusions and will thirstily look forward to your approaching updates. Saying thanks will not just be enough, for the wonderful clarity in your writing. I will instantly grab your rss feed to stay abreast of any updates. Admirable work and much success in your business enterprize!
Thank you for another informative blog post. Where else could I get that kind of info written in such a perfect way? I have a project that I am just now working on, and I have been on the look out for such information.
Hi there could I reference some of the information from this post if I reference you with a link back to your site?
I wanted to say that it’s nice to know that someone else also mentioned this as I had trouble finding the same info elsewhere. This was the first place that told me the answer. Thanks.
Hi. I wanted to drop you a quick note to express my thanks. I’ve been following your blog for a month or so and have picked up a ton of good information as well as enjoyed the way you’ve structured your site.
Fantastic post! I had been genuinely impressed through the good quality with the sources. Thanks a lot.
I appreciate you for the advice! Let me try it out.