Configure exim4 smtp relay server


This article will guide you to configure Exim4 SMTP relay server which will allow you to relay emails for the know Domains names and IP address only. In general, this type of service is used to relay emails for notifications for the server health status reports, where the actual email address does not exist or send auto response emails.

Introduction

Exim4 is a Message Transfer Agent (MTA) developed at the University of Cambridge for use on Unix systems connected to the internet. Exim4 can be installed to replace of Sendmail or Postfix, although the configuration of Exim4 is quite different to that of sendmail.

Installation

To install exim4, use the following command –

# hostname testserver.com
# sudo –i (to Enter with root permissions)
# apt-get update
# apt-get install exim4

The sample output should be like this –

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
exim4-base exim4-config exim4-daemon-light heirloom-mailx
Suggested packages:
mail-reader eximon4 exim4-doc-html exim4-doc-info spf-tools-perl swaks
Recommended packages:
mailx
The following NEW packages will be installed:
exim4 exim4-base exim4-config exim4-daemon-light heirloom-mailx
0 upgraded, 5 newly installed, 0 to remove and 66 not upgraded.
Need to get 1,862 kB of archives.
After this operation, 4,258 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://us.archive.ubuntu.com/ubuntu/ wily/main exim4-config all 4.86-3 ubuntu1 [299 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ wily/main exim4-base amd64 4.86-3ubuntu1 [869 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ wily/main exim4-daemon-light amd64 4.86-3ubuntu1 [465 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu/ wily/main exim4 all 4.86-3ubuntu1 [7,916 B]
Get:5 http://us.archive.ubuntu.com/ubuntu/ wily/universe heirloom-mailx amd64 12.5-5 [221 kB]
Fetched 1,862 kB in 49s (37.7 kB/s)
Preconfiguring packages ...
Selecting previously unselected package exim4-config.
(Reading database ... 91615 files and directories currently installed.)
Preparing to unpack .../exim4-config_4.86-3ubuntu1_all.deb ...
Unpacking exim4-config (4.86-3ubuntu1) ...
................................................

We need to configure exim4 to relay the emails.

# dpkg-reconfigure exim4-config

The output should be like this –

Select “internet site; mail is sent and received directly using SMTP” option

Provide the server name for the Exim4 SMTP server. By default, it will take the hostname of the machine.

Provide the IP address from which you want to receive the request and send emails.

Here, you can give a semicolon-separated list of IP address for multiple IP’s.

Enter the domain address of the clients’ recipient domains for which this SMTP will relay the mails.

Please note that, you can give a semicolon-separated list of domain address for multiple domains.

Enter a semicolon-separated list of IP address ranges for which this system will unconditionally relay mails. (Functioning as a smart host). This is generally the localhost which will be taken.

Select Keep number of DNS-queries minimal (Dial-on-Demand) to No ( previously, we used to have Dial-up connection, but currently most of the internet users are having broadband connections)

Select the delivery method for the local mail’s. Here, I have selected Maildir format in the home directory

Select Split configuration into small files? to No . If you are interested to store the configuration into small files, then you can choose YES

Now you are done and your SMTP servers which are ready to relay emails sent for any notifications. Use this machine IP or if registered domain then, use domain name in the SMTP server address in configurations.

After the configuration we can add the client using the same configuration command or we can directly edit the configuration file and add the additional client to use with this SMTP server.

Open the configuration file and edit or add the clients IP or domain names

# vi /etc/exim4/update-exim4.conf.conf

update-exim4.conf.conf file should be like this –

## Edit this file and /etc/mailname by hand and execute update-exim4.conf
# yourself or use 'dpkg-reconfigure exim4-config'#
# Please note that this is _not_ a dpkg-conffile and that automatically changes
# to this file might happen. The code handling this will honor your local
# changes, so this is usually fine, but will break local schemes that mess
# around with multiple versions of the file.
## update-exim4.conf uses this file to determine variable values to generate
# exim configuration macros for the configuration file.
## Most settings found in here do have corresponding questions in the
# Debconf configuration, but not all of them.
## This is a Debian specific file
dc_eximconfig_configtype='internet'
dc_other_hostnames='server.com'
dc_local_interfaces='127.0.0.1'
dc_readhost=''
dc_relay_domains='192.168.1.1'
dc_minimaldns='false'
dc_relay_nets='cgi.com'
dc_smarthost=''
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname=''
dc_mailname_in_oh='true'
dc_localdelivery='maildir_home'

Now, edit the following lines in the configuration with semicolon separated

dc_relay_nets are used to add the IP address of the client/servers

dc_relay_domains are used to add the domain names of the client/servers

After the successful configuration, you are allowed to use this server for sending or relaying emails from your servers and client for sending the notifications for your programs or projects.

Lakshmi Srinivas
Lakshmi Srinivas

Programmer / Analyst / Technician

Updated on: 18-Oct-2019

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements