Arvixe Web Hosting

Creating an Email Server with Sendmail and Dovecot - Part 1

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

Dovecot – We can download Dovecot from 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:

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.
# protocols = imap pop3
protocols = imap
disable_plaintext_auth = no
# Logging
log_path = /var/log/dovecot.log
info_log_path = /var/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 =
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:

  1. 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.
  2. 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
Connected to localhost.
Escape character is ‘^]’.
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.

Be Sociable, Share!

51 comments to Creating an Email Server with Sendmail and Dovecot – Part 1

  • Justin Immen

    I have been exploring on the net trying to get some ideas on how to get our website coded, your general design together with theme are fantastic. Did you code it by yourself or did you hire a programmer to get it done for you?

  • Shanna Thomes

    Excellent stuff.

  • Sherry J. Motley

    Good post, I like your website, thanks

  • backlinks

    Really great informative blog post here and I just wanted to comment & thank you for posting this. I’ve bookmarked youi blog and I’ll be back to read more in the future my friend! Also nice colors on the layout, it’s really easy on the eyes.

  • Gaston Pinkert

    Thank you! I really appreciate your article, in fact I think you deserve a thumbs up.

  • Claude Krupiak

    Some of the points associated with this blog post happen to be great. One point I have got to point out is certainly your writing abilities are very great and I will be returning back again for any new post you come up with, you may possibly have a new supporter. I book marked your main site for reference.

    • Ambar

      Great, if I may suggest, we rlaley need a feature to index & and calculate the number of messages/calender/contacs to be moved, and after the transition, how many that was succesfully moved. This is rlaley missing. /F

  • Rafael

    Excellent post. I used to be checking constantly this blog and I’m impressed!
    Very useful info particularly the remaining phase :) I maintain such information a lot.

    I was seeking this certain info for a long time.
    Thanks and good luck.

Leave a Reply



You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>