Debian 13: Configure Exim4 to deliver local mail to your external mail server

It's more convenient to read all your mail in one inbox. To have LogWatch or other reports delivered to your mailbox, Exim4 needs to be configured as smarthost.

Installation

In my case Exim comes as a dependency of LogWatch.

Configuration

Smarthost mode and your external mail server

Exim config /etc/exim4/update-exim4.conf.conf is below.

  1. Replace HOSTNAME with your actual hostname.
  2. Replace MAILHOST with your actual SMTP server.
dc_eximconfig_configtype='smarthost'
dc_other_hostnames='HOSTNAME'
dc_local_interfaces='127.0.0.1 ; ::1'
dc_readhost='HOSTNAME'
dc_relay_domains=''
dc_minimaldns='false'
dc_relay_nets=''
dc_smarthost='MAILHOST::587'
CFILEMODE='644'
dc_use_split_config='false'
dc_hide_mailname='true'
dc_mailname_in_oh='true'
dc_localdelivery='mail_spool'

From: addresses

File /etc/email-addresses. Exim uses this file as from: addresses, this is required for your external mail server to qualify the sender. Add the following records to use the addresses for your users:

root: SENDER@EMAIL.COM
user: SENDER@EMAIL.COM

To: addresses

File /etc/aliases. Exim uses records from this file as to: addresses, this is required for delivery to your external mail server. Add the following records to use the addresses for your users:

root: user
user: RECIPIENT@EMAIL.COM

Authentication with your mail server

File /etc/exim4/passwd.client. Exim uses credentials from the file to authenticate with your mail server. Add your account details to the file.

Since the password is stored in plain text, use a dedicated user which does not have sensitive information in it's mailbox.

### target.mail.server.example:login:password
MAILHOST:SENDER@EMAIL.COM:PASSWORD_IN_PLAIN_TEXT

Apply the configuration

sudo newaliases
sudo systemctl restart exim4

Verify delivery

Send mail:

$ mail root
Subject: This is a test
... of delivery to external mail server
.
Cc: 

Look at the delivery log:

sudo tail -f /var/log/exim4/mainlog

If there are no errors, you should receive the email.

If there are errors, check the configuration again and analyse output of the below command to see what's wrong: 

sudo exim -d -v RECIPIENT@EMAIL.COM < /dev/null

Don't forget to enjoy the reports!

This article was updated on September 5, 2025