By default, system emails are sent to the local root account. These emails can provide alerts and tips on the system health. This guide help you setup a redirection to an external email address (sysadmin’s one) for these emails.

This howto is tested on:

  • Debian 10.0 Buster


Set the external email address to which system emails are sent:



Detect if sudo is available (“command” is used if not):

command type -f 'sudo' &>'/dev/null' && cmdProxy='sudo'

SMTP server setup

Install the required software:

${cmdProxy} apt install 'exim4' 'bsd-mailx'

Use the current full hostname as the system mail domain (best default for a commercial dedicated server):

command hostname --fqdn \
    | ${cmdProxy} tee '/etc/mailname'

Setup the Exim 4 SMTP server as directly connected to the Internet (no relay SMTP used):

${cmdProxy} sed -i \
    -e "s|dc_eximconfig_configtype=.*\$|dc_eximconfig_configtype='internet'|" \
    -e "s|dc_other_hostnames=.*\$|dc_other_hostnames='$(command hostname --fqdn)'|" \
    -e "s|dc_use_split_config=.*\$|dc_use_split_config='true'|" \

Update Exim 4 configuration:

${cmdProxy} update-exim4.conf

Reload Exim 4 configuration:

${cmdProxy} systemctl restart 'exim4'

System emails redirection

Redirect emails sent to the local root account to the chosen email address:

${cmdProxy} sed -i \
    -e "s/^root:.*\$/root: ${sysadminEmail}/" \

Reload the email aliases configuration:

${cmdProxy} newaliases
Categories: Setup


Leave a Reply

Avatar placeholder

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.