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.

53 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

  • Kasey Bergman

    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

  • Gajda

    Great post. Hope to see even more excellent posts in the near future.

  • Hndms

    Took me time to read all the comments, but I really loved the article. It proved to be Very helpful to me.

  • Dennis Vashaw

    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

  • BMW 740

    Wonderful insight 🙂

  • Otterson

    Well dome mate!

  • Rosina Katowicz

    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.

  • Brent Thwaites

    Great blog post. Really looking forward to read more.

  • Jack Phaner

    Hmmm…very good to find out, there have been without a doubt a number of elements that I had not idea of before.

  • Hans Gulbransen

    Great blog post. Really looking forward to read more.

  • Wilmington

    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!

  • Pantleds

    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.

  • Lesli Bruh

    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!

  • Deandre Brozovich

    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.

  • Jeremy Relf

    Hi there could I reference some of the information from this post if I reference you with a link back to your site?

  • polarffour

    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.

  • abi

    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.

  • Damian Thaller

    Fantastic post! I had been genuinely impressed through the good quality with the sources. Thanks a lot.

  • Rory Guastella

    I appreciate you for the advice! Let me try it out.

  • Insurance Quotes

    Insightful. Inspirational. Beautifully Designed :). The experiences and skills gained through your website be carried throughout my professional career. If only everyone had the same level of perseverance. Ciao for now :). I hope this message is worthy of being posted.

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

    • Anil

      emails from his local machine from his PHP scpirts. Thankfully he’s found a solution and has shared it in a new blog post. Previously it was a simple trek to a website to download a Windows build of sendmail.exe, but

  • 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

  • Roland

    We absolutely love your blog and find nearly all of your post’s to
    be just what I’m looking for. Do you offer guest writers to write content to suit your needs?
    I wouldn’t mind composing a post or elaborating on a number
    of the subjects you write about here. Again, awesome web log!

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

  

  

  


*

This site uses Akismet to reduce spam. Learn how your comment data is processed.