Configuring Exim4 on Debian 9 for outbound mail

by | Oct 28, 2026 | Tutorials | 0 comments

Quick answer

Exim4 is Debian's default MTA and it is remarkably capable once you understand its split configuration.

Exim4 is Debian’s default MTA and it is remarkably capable once you understand its split configuration. For most sites you only need it to relay outbound mail reliably.

What you need: A Debian 9 server with exim4 installed and root access to reconfigure it.

Choose the right mode

Run dpkg-reconfigure exim4-config and choose “internet site; mail is sent and received directly” or the smarthost option if you relay through a provider.

Set the visible hostname

Make sure the “mail name” matches your domain and that your server hostname has valid forward and reverse DNS.

Test with a real recipient

Send to a test address and watch /var/log/exim4/mainlog. A “host lookup did not complete” means DNS; a remote 550 means your reputation or records.

dpkg-reconfigure exim4-config
echo 'test body' | mail -s 'exim test' [email protected]
tail -f /var/log/exim4/mainlog

How it works, in detail

Exim4’s split configuration hides most of the complexity behind a debconf wizard, but you still need to understand which mode you picked. The smarthost mode relays through a provider, which is the right choice when the server IP is residential or otherwise untrusted, while the direct-internet mode sends on its own. Whichever you choose, the hostname and reverse DNS must line up, or remote servers will reject the mail outright. Exim’s mainlog follows each message by ID, which makes failures unusually easy to trace.

Common pitfalls

  • Choosing direct delivery on an IP with no reverse DNS, guaranteeing rejection.
  • Ignoring the mainlog and guessing instead of following the message ID.

Pro tip

Send a test mail to yourself and follow its message ID through /var/log/exim4/mainlog end to end.

Exim4’s mainlog is unusually readable. Follow the message ID through the log and the delivery failure always explains itself.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

avatart

About

I’m a System Administrator and a developer with 10+ years of experience.