Operating System: Cent os 6.x / 7.x
Hostname: hostname [not a registered domain name, but you can use any domain name if you can set it as local domain in /etc/hosts]
Centos includes Postfix as default MTA in the repo. If you wish to install Exim on your Virtual machine or server, you need to enable third party packages in your repo, to do so: yum R1;enablerepo=extras install epel-release
Update your yum repo:yum update
Install Exim from repo:yum install exim
Enable Exim on server startup: systemctl enable exim.service
ORsystemctl enable exim
Start Exim:systemctl start exim
Install addtional tools such as vim, SPF libraries & openssl to setup a secure mail server:yum install file perl-Mail-SPF.noarch openssl vim
Assuming you have set a hostname for your virtual machine, let’s generate certificates for your hostname:
mkdir /root/SSL/mail.hostname -p
cd /root/SSL/mail.hostname/
openssl req -nodes -x509 -newkey rsa:2048 -keyout mail.hostname.key -out mail.hostname.crt -days 365
Let’s move Certificates to /etc/ssl:cp mail.hostname.crt mail.hostname.key /etc/ssl/
Let’s keep a backup for exim.conf before we edit the original:cp /etc/exim/exim.conf{,.orig}
Edit exim.conf file [look for following fields & replace hostname with your hostname.com] vi /etc/exim/exim.conf
primary_hostname = hostname
domainlist local_domains = @ : hostname
tls_certificate = /etc/ssl/mail.hostname.crt
tls_privatekey = /etc/ssl/mail.hostname.key
Look for: local_delivery & add /edit following lines:
driver = appendfile
delivery_date_add
envelope_to_add
return_path_add
directory = $home/Maildir
maildir_format
maildir_use_size_file
group = mail
mode = 0660
Let’s add dovecot as mailbox authenticator with Exim so dovecot can IMAP / POP emails:
dovecot_login:
driver = dovecot
public_name = LOGIN
server_socket = /var/run/dovecot/auth-client
server_set_id = $auth1
dovecot_plain:
driver = dovecot
public_name = PLAIN
server_socket = /var/run/dovecot/auth-client
server_set_id = $auth1
Now, we need to install IMAP software which is Dovecot:
yum install dovecot
systemctl start dovecot
systemctl enable dovecot
Configuring dovecot & ask to listen to specific ports & use Exim as authSMTP:
Adding SSL for dovecot:
Command: vim /etc/dovecot/conf.d/10-ssl.conf
ssl_cert = </etc/ssl/mail.hostname.crt
ssl_key = </etc/ssl/mail.hostname.key
Disable plaintext authentication:
Command: vim /etc/dovecot/conf.d/10-auth.confdisable_plaintext_auth = no
Setup mailbox path:
vim /etc/dovecot/conf.d/10-mail.conf
mail_location = maildir:~/Maildir
Setup Dovecot to auth with Exim: vim /etc/dovecot/conf.d/10-master.conf
unix_listener auth-userdb {
mode = 0660
user = exim
}
Send a test email:
Command: mail -s “Test Email” username@hostname.com < /dev/null
and check your exim log.
That’s all! We now have installed Exim & Dovecot and configured as they both work together as IMAP / SMTP servers for your machine.