Updating Postfix's virtual alias maps
Posted November 18th, 2007 in Email Servers
Postfix allows you to store virtual alias maps in a text file, which tells postfix how to route virtual email addresses to real users on the system. This setting and the file location is determined in the postfix configuration file /etc/postfix/main.cf like so:
virtual_alias_maps = hash:/etc/postfix/virtual
The format of the file is with the alias on one side, and the destination on the other, for example like so:
john_smith@example.com john john-smith@example.com john fred@example.com john
This routes all email addressed to john_smith@example.com, john-smith@example.com and fred@example.com to the real user (or system alias) john. It's possible to have a catch-all alias which will route anything addressed to @example.com to a particular user like so:
@example.com john
If you wanted everything to go to "john" except for mail to fred@ then you can do it like this:
@example.com john fred@example.com fred
Just editing the /etc/postfix/virtual file is not enough to make the changes take affect. You must run the postmap command to make postfix read the file, like so:
/usr/sbin/postmap /etc/postfix/virtual
This creates a new file called /etc/postfix/virtual.db and the aliases are now loaded into postfix.
Subscribe!
If you found this post interesting and would like to be notified the next time something is posted, please subscribe to my RSS Feed. Thanks for visiting!

