Content:
Out of the box, email addresses handled on your system used by Postfix will match the names of the system user accounts that are available. This includes the system root account.
While this makes initial setup faster, there are many cases where this setup would not be suitable.
Fortunately, Postfix supports email aliases, which allow a more flexible setup.
Standard Configuration
For this example, consider a mail server with the domain name example.com
. By default, if your system has an account named user
, emails to user@example.com
will land in the inbox for user
.
Assuming user is the only user account on the system, other emails (excluding root@
and postmaster@,
which we’ll discuss later) will be ignored. This is because there’s no receiving mailbox for Postfix to transfer the email to. It has no choice but to reject the email.
Special Addresses
root@
and postmaster@
can be considered special email accounts.
root@
works similarly to any other account – your system will have a root account by default, albeit one you generally can’t log in to. Some processes, such as cron, will send emails as the root@
user in the event a cron job fails. Other system processes will also communicate using root@
, assuming email support is available.
You might start seeing emails landing in your mailbox from root@
once you have Postfix set up.
The postmaster@
address can be considered to be the account for the email system administrator. Issues such as rejected emails will be communicated to the sender using the postmaster@
address. For example, if you send an email to a non-existent recipient, postmaster@
will be the one to send the bounce message.
This is not strictly related to email aliasing, but it’s useful to be aware that these accounts will exist on your system.
Creating an Alias
To add new aliases, we need to edit the /etc/aliases
file. This file maps incoming email targets to either an actual user account on the system, or an external email address.
Adding an alias is simple. Add a line to /etc/aliases
, containing the target email address (minus the domain), followed by the address to direct the email to.
getintouch qubitsandbytes
In the example above, emails sent to getintouch@example.com
will be directed to the mailbox belonging to the qubitsandbytes
user account on the system.
To add an external email address, the full email address is required.
getintouch contact@second-example.com
Here, emails for getintouch@example.com
will be redirected to contact@second-example.com
.
The same destination can be used for multiple addresses, though only one rule can be applied for each incoming address.
Save the modified file, and run newaliases
to load the new aliases file into Postfix.
Your emails will now be forwarded to the alias specified in /etc/aliases
, allowing a theoretically unlimited number of email addresses without having to set up a new mailbox for each one.