Email & webmail

Configure Exim4 on Debian and Ubuntu (without a control panel)

Install and configure Exim4 on Debian or Ubuntu with dpkg-reconfigure: choose internet site, smarthost or local-only modes, split vs single config, TLS, and testing with exim -bt.

AdvancedDebian and Ubuntu servers2 min read

Exim4 is the default mail transfer agent on Debian and is available on Ubuntu. The Debian packaging wraps Exim's powerful configuration in a guided setup, so you can run a send-only server, a smarthost client or a full internet mail server quickly. This guide configures Exim4 on Debian and Ubuntu without a control panel.

Before you start

  • A Debian or Ubuntu server with root access and a fully qualified hostname.
  • DNS (A, PTR, MX if receiving) set for the mail hostname.
  • Don't use this on cPanel servers – cPanel manages its own Exim build.

Install Exim4

sudo apt install -y exim4-daemon-light

Use exim4-daemon-heavy if you need features such as SQL lookups or advanced content scanning.

Run the guided configuration

sudo dpkg-reconfigure exim4-config
ModeUse it for
internet siteSend and receive mail directly via SMTP
mail sent by smarthost; received via SMTP or fetchmailSend through a relay, still receive
mail sent by smarthost; no local mailSend-only through a relay (common for app servers)
local delivery onlySystem mail stays on the machine

Other questions: the system mail name (your domain), IP addresses to listen on (127.0.0.1 ; ::1 for send-only), domains to accept mail for, and whether to split the configuration into small files.

Split vs single configuration

  • Split – many files under /etc/exim4/conf.d/; easy to add snippets.
  • Single – one template /etc/exim4/exim4.conf.template.

Either way, put your own macros in /etc/exim4/conf.d/main/00_local_macros (split) or at the top of the template, then regenerate and restart:

sudo update-exim4.conf && sudo systemctl restart exim4

Smarthost credentials

For relay mode, add a line to /etc/exim4/passwd.client:

smtp.relay.example:username:password

Restrict permissions with chmod 640 and group Debian-exim.

Enable TLS for incoming connections

  1. Add to your local macros:
    MAIN_TLS_ENABLE = yes
    MAIN_TLS_CERTIFICATE = /etc/exim4/exim.crt
    MAIN_TLS_PRIVATEKEY = /etc/exim4/exim.key
  2. Copy your certificate and key there (readable by the Debian-exim group) via a Certbot deploy hook.
  3. Run update-exim4.conf and restart.

Test Exim

  • Show how an address would be routed: sudo exim -bt user@example.com
  • Send a test: echo 'Test' | mail -s 'Exim test' you@yourmail.com
  • Watch the log: sudo tail -f /var/log/exim4/mainlog
  • Check the queue: sudo exim -bp

Troubleshooting

  • Changes don't apply: you edited files but didn't run update-exim4.conf.
  • "Mailing to remote domains not supported": mode is local-only – rerun dpkg-reconfigure.
  • Relay authentication fails: wrong passwd.client format or host name not matching the smarthost.
  • Panic log entries: read /var/log/exim4/paniclog and clear it once fixed.

FAQ: Exim4 on Debian

Exim or Postfix on Debian?

Both work well. Exim is the Debian default; Postfix is more common in tutorials for full mail servers.

Is exim4 the same as cPanel's Exim?

Same software, different packaging and configuration. Don't mix instructions between them.

How do I receive mail into mailboxes?

Exim delivers to local Maildirs or hands mail to Dovecot via LMTP; add Dovecot for IMAP access.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.