Configuring Sendmail and Dovecot under Fedora

Do not use these instructions to build a internet facing server!

This guide explains how to create a simple IMAP + SMTP server to test email clients on a local machine. All the users of the imap server are stored under a single system account vmail, the users are auto-created and have the same password.

First install the following packages:

yum install sendmail-cf sendmail dovecot

Then configure sendmail as follows:

--- ./etc/mail/mailertable  2014-02-11 17:25:37.000000000 +0100
+++ /etc/mail/mailertable 2014-04-11 19:30:44.419085821 +0200
@@ -28,3 +28,5 @@
#
# will give an error message with the indicated SMTP reply code and message,
# where D.S.N is an RFC 1893 compliant error code.
+
+test-carteggio.com dovecot:test-carteggio.com
 
--- ./etc/mail/sendmail.mc 2014-02-11 17:25:37.000000000 +0100
+++ /etc/mail/sendmail.mc 2014-04-11 19:29:59.316234906 +0200
@@ -173,6 +173,8 @@
dnl MASQUERADE_DOMAIN(localhost.localdomain)dnl
dnl MASQUERADE_DOMAIN(mydomainalias.com)dnl
dnl MASQUERADE_DOMAIN(mydomain.lan)dnl
+MAILER_DEFINITIONS
+MAILER(dovecot)dnl
MAILER(smtp)dnl
MAILER(procmail)dnl
dnl MAILER(cyrusv2)dnl
 
--- ./etc/mail/virtusertable 2014-02-11 17:25:37.000000000 +0100
+++ /etc/mail/virtusertable 2014-04-09 21:14:44.959560483 +0200
@@ -39,3 +39,5 @@
# MASQUERADE_DOMAIN and MASQUERADE_DOMAIN_FILE). If VIRTUSER_DOMAIN or
# VIRTUSER_DOMAIN_FILE is used, then the entries of class {VirtHost} are
# added to class {R}, i.e., relaying is allowed to (and from) those domains.
+
+@test-carteggio.com vmail
 
--- .//usr/share/sendmail-cf/mailer/dovecot.m4 1970-01-01 01:00:00.000000000 +0100
+++ /usr/share/sendmail-cf/mailer/dovecot.m4 2014-04-12 15:51:29.391065914 +0200
@@ -0,0 +1,7 @@
+Mdovecot, P=/usr/libexec/dovecot/dovecot-lda,
+ F=l59DFMPhnu,
+ S=EnvFromL/HdrFromL, R=EnvToL/HdrToL,
+ M=51200000,
+ U=vmail:vmail,
+ T=DNS/RFC822/X-Unix,
+ A=/usr/libexec/dovecot/dovecot-lda -d $u

Diff

Then configure dovecot:

--- ./etc/dovecot/conf.d/10-auth.conf   2013-04-17 15:59:47.000000000 +0200
+++ /etc/dovecot/conf.d/10-auth.conf 2014-04-09 20:44:32.488856676 +0200
@@ -125,4 +125,4 @@
#!include auth-passwdfile.conf.ext
#!include auth-checkpassword.conf.ext
#!include auth-vpopmail.conf.ext
-#!include auth-static.conf.ext
+!include auth-static.conf.ext
 
--- ./etc/dovecot/conf.d/10-mail.conf 2014-02-14 13:13:38.000000000 +0100
+++ /etc/dovecot/conf.d/10-mail.conf 2014-04-11 07:40:19.798663341 +0200
@@ -27,7 +27,7 @@
#
# <doc/wiki/MailLocation.txt>
#
-#mail_location =
+mail_location = maildir:~/Maildir

# If you need to set multiple mailbox locations or want to change default
# namespace settings, you can do it by defining namespace sections.
 
--- ./etc/dovecot/conf.d/auth-static.conf.ext 2013-05-19 22:18:00.000000000 +0200
+++ /etc/dovecot/conf.d/auth-static.conf.ext 2014-04-09 20:44:46.736785284 +0200
@@ -13,10 +13,10 @@
# args = proxy=y host=%1Mu.example.com nopassword=y
#}

-#passdb {
-# driver = static
-# args = password=test
-#}
+passdb {
+ driver = static
+ args = password=test
+}

#userdb {
# driver = static
 
--- ./etc/dovecot/conf.d/auth-system.conf.ext 2013-05-19 22:18:00.000000000 +0200
+++ /etc/dovecot/conf.d/auth-system.conf.ext 2014-04-12 15:55:11.526683206 +0200
@@ -7,12 +7,12 @@
# PAM is typically used with either userdb passwd or userdb static.
# REMEMBER: You'll need /etc/pam.d/dovecot file created for PAM
# authentication to actually work. <doc/wiki/PasswordDatabase.PAM.txt>
-passdb {
- driver = pam
+#passdb {
+# driver = pam
# [session=yes] [setcred=yes] [failure_show_msg=yes] [max_requests=<n>]
# [cache_key=<key>] [<service name>]
#args = dovecot
-}
+#}

# System users (NSS, /etc/passwd, or similiar).
# In many systems nowadays this uses Name Service Switch, which is
@@ -46,19 +46,19 @@

# System users (NSS, /etc/passwd, or similiar). In many systems nowadays this
# uses Name Service Switch, which is configured in /etc/nsswitch.conf.
-userdb {
+#userdb {
# <doc/wiki/AuthDatabase.Passwd.txt>
- driver = passwd
+# driver = passwd
# [blocking=no]
#args =

# Override fields from passwd
#override_fields = home=/home/virtual/%u
-}
+#}

# Static settings generated from template <doc/wiki/UserDatabase.Static.txt>
-#userdb {
- #driver = static
+userdb {
+ driver = static
# Can return anything a userdb could normally return. For example:
#
# args = uid=500 gid=500 home=/var/mail/%u
@@ -70,5 +70,5 @@
# the user verification another way, you can add allow_all_users=yes to
# the args in which case the passdb lookup is skipped.
#
- #args =
-#}
+ args = uid=1001 gid=12 home=/var/mail/vmail/%u
+}
 
--- ./etc/dovecot/dovecot.conf 2013-05-19 22:17:04.000000000 +0200
+++ /etc/dovecot/dovecot.conf 2014-04-09 20:44:16.552936655 +0200
@@ -22,6 +22,7 @@

# Protocols we want to be serving.
#protocols = imap pop3 lmtp
+protocols = imap

# A comma separated list of IPs or hosts where to listen in for connections.
# "*" listens in all IPv4 interfaces, "::" listens in all IPv6 interfaces.

Diff

Finally create the folder /var/mail/vmail and give write permissions to user vmail.