Subscribe to RSS feed

«

»

Nov
26

Virtual Email Domains in Postfix

There are several ways to implement virtual email hosting with Postfix. I will only be covering on of them, using the VIRTUAL_ALIAS configuration directive to dump incoming mail to local user accounts and/or forwarding. Set is pretty straight forward. First, edit the Postfix configuration file, on Linux systems it’s usually /etc/postfix/main.cf. Add the following lines to the configuration file replacing example.com with the domain you wish to receive mail for:
virtual_alias_domains = example.com
virtual_alias_maps = hash:/etc/postfix/virtual
This specifies we wish to receive mail for example.com and to look in the /etc/postfix/virtual file for a list of users we accept mail for.

Next we need to create our virtual user list, edit the file /etc/postfix/virtual. Now by default you may find a bunch of help text in the file, you can ignore this and put you edits in there anyway, delete the content, or my favorite, move the file and create a fresh one:
mv /etc/postfix/virtual /etc/postfix/virtual.orig
touch /etc/postfix/virtual

Now we can add out entries to the file, let’s start with these:
jeff@example.com jeff
chris@example.com chris
ed@example.com ed
sales@example.com jeff
support@example.com chris
@example.com bob
In this example, the first three lines except mail for those users and deliver it directly to their local mailboxes. Lines 4 and 5 have a different address deliver mail to Jeff and Chris. And finally the last line is a “catch-all” address, this is usually very bad to have configured and WILL overwhelm the account it is pointed to, the catch-all will pick up any addresses not specified and will be a boon for spammers everywhere. But in this case we don’t really like Bob so he gets all the nasty mail.

Finally all we need to do is hash out the virtual file and restart Postfix:
postmap /etc/postfix/virtual
service postfix restart

1 comment

  1. dog arthritis pain says:

    dog arthritis pain…

    Merely wanted to point out that your page is awesome. Very clear and well laid out….

Leave a Reply

  • Facebook
  • Picasa