Networking HowTos
Networking HowTos

Sendmail mail aliases

June 13, 2013 Linux

The sendmail smtp mail server is able to set up mailbox aliases which can be used to forward mail to specific users, or even other aliases. This can be done by simply editing a configuration file called ‘aliases’ that is generally located in /etc/mail/aliases. This guide will show you how to set up alises for use with Sendmail.

Example aliases file:

#
# Mail aliases for sendmail
#
# You must run newaliases(1) after making changes to this file.
#
# Required aliases
postmaster:	root
MAILER-DAEMON:	postmaster
# Common aliases
abuse:		postmaster
spam:		postmaster
# Other aliases
mailinglist:    user1,user2,root

The aliases file is simply made up of 2 values, the alias name on the left, a colon seperater, and the destination name on the right. The destination section can contain multiple destinations seperated by commas.
Edit the file in your favorite text editor to suit your needs.

$ sudo nano /etc/mail/aliases

Once you have the aliases configuration file set up the way you want, you need to use that plain text file to update the random access database aliases.db file using the newaliases command as follows:

$ sudo newaliases

eg:

$ sudo newaliases
/etc/mail/aliases: 5 aliases, longest 16 bytes, 93 bytes total

You could also run the following instead:

$ sudo sendmail -bi

Note: dont use the makemap command to generate the aliases.db file as the newaliases command puts a special token into the database file that is needed for sendmail.

You Might Also Like