dracoblue.net

Alias and Virtual Domains with Postfix

Today I ran into the case, that I have my ubuntu server with postfix running as MTA. Since there is no IMAP server or something like this installed, I use this server only for relaying/proxying the mails to my gmail account.

Setup was straight forward (choose "Internet Site" and enter the ip of the server when it asks for mynetworks):

# apt-get install postfix

The /etc/aliases looks like this:

if I want to send all mails from root to the mail address [email protected].

This all went well, as long as there was only one domain running on the server. Let's say the first domain was example.org and the second one is example.net.

That's why I had to reconfigure the postfix program:

# dpkg-reconfigure postfix

When it asked for the local servers (mynetworks in main.cf) I added example.net at the end.

Now I want that [email protected] and [email protected] mails, will be received by [email protected]. Additionally everything to [email protected] will be send to [email protected].

But to make everything working (like Jem explained), I had to modify /etc/aliases and create + modify the /etc/postfix/virtual file.

First of all we need some virtual mapping for the email accounts to local aliases in /etc/postfix/virtual (create it if it does not exist, yet):

example.net this-text-is-not-important
[email protected] bob-dracoblue-net
[email protected] bob-dracoblue-net
[email protected] alice-dracoblue-net

To enable virtual aliases add/change the line to /etc/postfix/main.cf:

virtual_alias_maps = hash:/etc/postfix/virtual

Update the postfix table map for the virtual file with:

# postmap /etc/postfix/virtual

Then the local aliases need to be mapped to real email addresses (append to /etc/aliases:

alice-dracoblue-net: [email protected]
bob-dracoblue-net: [email protected]

To reload the aliases run:

# newaliases

Eventually you have to run:

# postfix reload

to finalize the setup.

Check /var/log/system.log with:

# tail -f /var/log/system.log

and try to send/receive mails! Have fun!

In open source, postfix, ubuntu by @ 30 Dec 2013

comments powered by Disqus

Recent Files

Advertisement

Recent Dev-Articles

Read recently

About

Blogroll