The Fedora 20 Active Directory Integration Guide : Mail Server

With Fedora 20 you don’t need to run Microsoft Exchange if you want your corporate email users to login to the mail server with the domain accounts.  In this example, we will setup a simple mail server using sendmail and dovecot.

First, make sure you have joined the domain.  Because dovecot uses PAM for authentication by default, the server is now automatically configured to accept requests from domain users. Then install sendmail as your MTA.

#yum install sendmail sendmail-cf

Next, install dovecot to use as your MDA / POP3 server.

#yum install dovecot

Since this is only a mail server and we don’t want users actually logging in through SSH we will make a set of virtual home directories for them.  This requires creating a user and group that will hold all the mail.

#groupadd -g 5000 vmail
#useradd -u 5000 -g 5000 -d /var/vmail vmail

We will need to tell dovecot where to put the mail and what format to keep it in.

#vi /etc/dovecot/conf.d/10-mail.conf

Update the following line.

mail_location = maildir:/var/vmail/%u/Maildir

Now we will have to configure dovecot to run as the user that has access to the mail directories instead of its default of running as the user who is logged in checking mail.

#vi /etc/dovecot/conf.d/auth-system.conf.ext

comment out any userdb sections and update the static settings to the following.

# Static settings generated from template <doc/wiki/UserDatabase.Static.txt>
userdb {
driver = static
args = uid=5000 gid=5000 home=/var/vmail/%u allow_all_users=yes
}

Next, we will need to configure sendmail to use dovecot as the LDA so the mail ends up in the right place.

#vi /etc/mail/sendmail.mc

Make the following changes.

FEATURE(local_procmail, `/usr/libexec/dovecot/dovecot-lda', `/usr/libexec/dovecot/dovecot-lda -d $u')dnl
MODIFY_MAILER_FLAGS(`LOCAL',`-f')dnl

With the same file still open, finish configurating sendmail to accept mail for your domain and fix the headers for any relayed mail from your other servers.

DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl
LOCAL_DOMAIN(`corp.mydomain.com')dnl
MASQUERADE_AS(`corp.mydomain.com')dnl
FEATURE(masquerade_envelope)dnl
FEATURE(masquerade_entire_domain)dnl
MASQUERADE_DOMAIN(corp.mydomain.com)dnl

Now update the sendmail configuration.

#cd /etc/mail
#make
#systemctl restart sendmail.service

Configure the firewall to allow mail traffic.

#firewall-cmd --permanent --add-service=pop3
#firewall-cmd --add-service=pop3
#firewall-cmd --permanent --add-service=smtp
#firewall-cmd --add-service=smtp