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-lightUse exim4-daemon-heavy if you need features such as SQL lookups or advanced content scanning.
Run the guided configuration
sudo dpkg-reconfigure exim4-config| Mode | Use it for |
|---|---|
| internet site | Send and receive mail directly via SMTP |
| mail sent by smarthost; received via SMTP or fetchmail | Send through a relay, still receive |
| mail sent by smarthost; no local mail | Send-only through a relay (common for app servers) |
| local delivery only | System 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 exim4Smarthost credentials
For relay mode, add a line to /etc/exim4/passwd.client:
smtp.relay.example:username:passwordRestrict permissions with chmod 640 and group Debian-exim.
Enable TLS for incoming connections
- Add to your local macros:
MAIN_TLS_ENABLE = yes MAIN_TLS_CERTIFICATE = /etc/exim4/exim.crt MAIN_TLS_PRIVATEKEY = /etc/exim4/exim.key - Copy your certificate and key there (readable by the
Debian-eximgroup) via a Certbot deploy hook. - Run
update-exim4.confand 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.clientformat or host name not matching the smarthost. - Panic log entries: read
/var/log/exim4/paniclogand 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.
