How to Create & Manage Exim email aliases

In our previous article, we created an Exim email server and configured it to send email. We learnt how to create email accounts and the correct settings required to set up our email account in Outlook. Now we’re going to focus on email aliases when using Exim. Exim Email aliases are redirects for email. We can redirect local mail to other email addresses using the /etc/aliases file. As well as routing email to different domains we can also route email for email accounts that don’t exist. If you want to route [email protected] and [email protected] to your email account you could use the aliases file to achieve this.

This article is part of a series of articles about setting up and managing Exim Email Servers.

  1. Install Exim on CentOS/RockyLinux Servers
  2. Install Exim on Ubuntu/Debian Servers
  3. Set up Exim Email Aliases (This Article)
  4. Install RoundCube To Access Webmail
  5. Use your Exim Email Server as a SmartHost Relay

Forward Root Email

If you want to forward all emails for the root user to an email account you have created on your email server you just need to edit the /etc/aliases. Open up the file and add or change the very bottom line.

nano /etc/aliases
root:           server

So, this would send all root email to the email account [email protected]. Save and close the file then test your new configuration by sending a test mail to the root account using the command below. You should get the test email in your [email protected] email account

echo Hi | mailx root

Create New Exim Email Aliases

As well as forwarding the root email to our email account we can forward mail for users that don’t have an email account on the server. We’re going to forward mail sent to [email protected] and [email protected] to our [email protected] email account.

nano /etc/aliases
 Aliases in this file will NOT be expanded in the header from
 Mail, but WILL be visible over networks or from /bin/mail.
 >>>>>>>>>>      The program "newaliases" must be run after
 >> NOTE >>      this file is updated for any changes to
 >>>>>>>>>>      show through to sendmail.
 Basic system aliases -- these MUST be present.
 mailer-daemon:  postmaster
 postmaster:     root
 General redirections for pseudo accounts.
 bin:            root
 daemon:         root
 adm:            root
 lp:             root
 sync:           root
 shutdown:       root
 halt:           root
 mail:           root
 news:           root
 uucp:           root
 operator:       root
 games:          root
 gopher:         root
 ftp:            root
 nobody:         root
 radiusd:        root
 nut:            root
 dbus:           root
 vcsa:           root
 canna:          root
 wnn:            root
 rpm:            root
 nscd:           root
 pcap:           root
 apache:         root
 webalizer:      root
 dovecot:        root
 fax:            root
 quagga:         root
 radvd:          root
 pvm:            root
 amandabackup:           root
 privoxy:        root
 ident:          root
 named:          root
 xfs:            root
 gdm:            root
 mailnull:       root
 postgres:       root
 sshd:           root
 smmsp:          root
 postfix:        root
 netdump:        root
 ldap:           root
 squid:          root
 ntp:            root
 mysql:          root
 desktop:        root
 rpcuser:        root
 rpc:            root
 nfsnobody:      root
 pcp:            root
 ingres:         root
 system:         root
 toor:           root
 manager:        root
 dumper:         root
 abuse:          root
 newsadm:        news
 newsadmin:      news
 usenet:         news
 ftpadm:         ftp
 ftpadmin:       ftp
 ftp-adm:        ftp
 ftp-admin:      ftp
 www:            webmaster
 webmaster:      root
 noc:            root
 security:       root
 hostmaster:     root
 info:           postmaster
 marketing:      postmaster
 sales:          postmaster
 support:        postmaster
 noaccount:      server
 noaccount1:     server
 #trap decode to catch security attacks
 decode:         root

 #Person who should get root's mail
 root:           server

Exim Email Aliases

Here we have added the following code to the /etc/aliases file. This forwards all emails for [email protected] and [email protected] to our [email protected] account. The accounts don’t have to exist in the email server for this to work.

noaccount:      server
noaccount1:     server
exim aliases

You can test the changes by simulating email delivery like we did with the root account. When using Exim and email aliases you do not need to restart the mail server.

echo Hi | mailx noaccount

You can also send an email to the new email aliases. Try sending mail to your [email protected] email address and it should be routed to your [email protected] email account.

Forward Email To External Domains

We can also use the /etc/aliases file to send mail to domains not located on this server. Instead of specifying the local user, you can specify an email address. If you followed our Exim setup guide there is no further configuration needed to send to an offsite domain.


Related Articles

Leave a Reply

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

Back to top button