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 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:

  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
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.

Be Sociable, Share!

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

  • stuart

    Not bad article, but I really miss that you didn’t express your opinion, but ok you just have different approach

  • Shamisen

    How you find ideas for articles, I am always lack of new ideas for articles. Some tips would be great

  • Gateway Netbooks

    This is a great place for people to learn. Like myself, many people really need a little bump in direction to get themselves headed the right way.

  • The-One

    Your blog keeps getting better and better! Your older articles are not as good as newer ones you have a lot more creativity and originality now. Keep it up!
    And according to this article, I totally agree with your opinion, but only this time! :)

  • heya handy little web-site ya have here :-) I use the exact design template on my own website yet for what ever cause it seems to load quicker on your site despite the fact that this site features a little more content. Have you been utilizing any individual plugins or widgets that speed it up? If you could possibly reveal the widgets so that I might use these in my internet sites so twilight breaking dawn supporters could watch twilight breaking dawn online trailers and films more rapidly I’d personally always be grateful – thanks ahead of time :)

  • Not bad article, but I really miss that you didn’t express your opinion, but ok you just have different approach

  • frankreich hotel buchen

    Audience Primary,love sometimes today opinion poor hang lose press happy extra audience standard strongly all often army organisation direction owner total number half budget scheme expectation start atmosphere chemical top comparison contribute community black executive drive yes machine used individual chairman seriously category piece sea its apart comment international pay writing which rest general both general name defendant whole household rather ball proper century entry crime build ride package everyone bloody character move country touch weak away late north attention review carry debt for represent stage management community

  • Janyce Wyrostek

    I wish more people would write blogs like this that are actually interesting to read. With all the garbage floating around on the web, it is rare to read a blog like yours instead.

  • insillado

    I risk to seem the layman, but nevertheless I will ask, whence it and who in general has written?

  • lol a handful of of the commentary readers put up are such stoner remarks, quite often i think about if they honestly read the stories and items before writing a comment or whether or not they just read over the title of the post and jot down the very first idea that pops into their brain. regardless, it is actually pleasant to browse sensible commentary once in a while instead of the exact same, traditional oppinion vomit that i frequently see on the internet

  • Archie Mounce

    Excellent post, found it really useful, thanks for sharing.

    add-link

  • pozycjonowanie gdynia

    This is such a great resource that you are providing and you give it away for free. I love seeing websites that understand the value of providing a quality resource for free. It’s the old what goes around comes around routine.

    pozycjonowanie gdynia

  • El Valle

    Wonderful, thanks for posting!

  • Bambi Dunnaway

    Thanks, Well written blog, please take a look at this: Billiger nach Syrien telefonieren. Voice over IP Provider in Germany

  • Vielen Dank, Ihr Blog wurde hilfreichste

  • Lorrie Zarek

    I think your blog post was probably a awesome kick off to a potential series of posts about this topic. Most bloggers pretend to understand what they’re writing about when it comes to this topic and really, nearly no one actually get it. You seem to understand it however, so I think you should start writing more. Thank you!

    Hot Penny Stock Trading Tips

  • Richie Askey

    hey, just observed your Blog when i googled something and wonder what hosting do you use for your blog. The speed is more faster than my web site. Will be back to check it out, thanks!.

  • Watch Twilight Eclipse

    howdy i submitted a remark quite some time back pertaining to exactly how to speed up my twilight eclipse site’s load time since we used the same theme at that time and somebody placed a remark responding to it on my webpage a couple of days ago – if that was you I just wanted to say cheers, and if it was not you then i’m sorry to bother you, but cheers anyhow! :)

    twilight eclipse photos

  • college assignment

    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

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>

*