Configuring Exim4 on Ubuntu
Configuring Exim4 on Ubuntu
Exim4 is a message transfer agent (MTA) that can be used on Unix systems connected to the internet and can be installed in place of sendmail or Postfix.
Prerequisites
- SMTP credentials of Mail relay servers (brevo or Amazon SES)
Installation
1
apt install exim4 -y
Configuration Steps via wizard
The dpkg-reconfigure exim4-config
command opens a user interface to configure the exim4 mail agent.
- Mail Server configuration type: Select
mail sent by smarthost; received via SMTP or fetchmail
. - Mail Name: Use system hostname.
- IP Addresses to listen for incoming SMTP connections:
127.0.0.1
. - Other Hostnames (or) Other Destinations: Use system hostname.
- Mail relay machines: Leave this as blank.
- IP Address or Hostname of SMTP Smarthost: Relay server IP address or Hostname with Port. (e.g.,
smtp-relay.brevo.com::587
) - Hiding local mail name: Select
Yes
. - Visible domain name for local users:
- Blank: Then the From Address will be
user@hostname
. (e.g.,root@app-server-1
) - example.com: Then the From Address will be
root@example.com
.
- Blank: Then the From Address will be
- Dial-on-Demand: Select
No
. - Delivery method: Select
mbox format in /var/mail/
. - Split Configuration: Select
No
.
All configurable parameters from the user interface are stored in the /etc/exim4/update-exim4.conf.conf
file. We can reconfigure the exim4 settings by re-running the wizard or manually wditing the file.
Resulting Configuration File
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# /etc/exim4/update-exim4.conf.conf
#
# 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 automatic 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='smarthost'
dc_other_hostnames='app-server-1'
dc_local_interfaces='127.0.0.1'
dc_readhost='example.com'
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost='smtp-relay.brevo.com::587'
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname='true'
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'
Mail name is stored in /etc/mailname
file.
1
2
root@app-server-1:~# cat /etc/mailname
app-server-1
SMTP Authentication
To configure the SMTP Authentication credentials, edit /etc/exim4/passwd.client
file.
1
2
3
4
5
6
7
8
9
10
11
12
# Filename: /etc/exim4/passwd.client
# Purpose: Setup SMTP Credentials for exim4
# password file used when the local exim is authenticating to a remote
# host as a client.
#
# see exim4_passwd_client(5) for more documentation
#
# Example:
### target.mail.server.example:login:password
smtp-relay.brevo.com:12345678@smtp-brevo.com:password@123
Setting up /etc/aliases
The /etc/aliases
file is used to create email aliases. To set up aliases for all users to include root and for root to include a Gmail address:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# /etc/aliases
mailer-daemon: postmaster
postmaster: root
nobody: root
hostmaster: root
usenet: root
news: root
webmaster: root
www: root
ftp: root
abuse: root
noc: root
security: root
root: sysadmin@example.com, example@gmail.com
monit: root
This post is licensed under CC BY 4.0 by the author.