Postfix relayhost and aliases

I spent a few hours today figuring out why the /etc/aliases file was ignored by postfix. Mail to root was being delivered to root@exampl.tld instead of being rewritten by the /etc/aliases file. The solution is to use virtual_alias_maps instead.

In /etc/postfix/main.cf remove the alias_maps and alias_database like so:

#alias_maps = hash:/etc/aliases
#alias_database = hash:/etc/aliases
virtual_alias_maps = hash:/etc/postfix/virtual

Then add something like this to /etc/psotfix/virtual:

root    realuser@example.tld
user    realuser@example.tld

To make that active run:

sudo postmap /etc/postfix/virtual
sudo service postfix reload

I’m sure I figured all this out years ago, but if I did, I’d forgotten it all today!

Advertisements

5 thoughts on “Postfix relayhost and aliases”

  1. Thanks for this! I still don’t know why the original aliases were being ignored for me, though.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s