First, I would like to thank you for your time.

I've come to the following situation:

  • I've got a mail server named mx1.domain.com

  • This mail server is virtual hosting some domains mail accounts like user1@somedomain.org, user1@someotherdomain.net

  • As long as the hostname for the server is (and should be so the SMTP Banner is the same hostname as the IP rdl to) mx1.domain.com the default Postfix accounts and server accounts postmaster@mx1.domain.com hostmaster@mx1.domain.com ... are binded to the real hostname, not virtuals.

  • I've got a simple user for login through ssh, and I've set up my /etc/aliases so the email for all those 'default' addresses go to root user and then I set up root mail to get into my login user instead.

How can I get all those emails, that my system and users send to those default addresses on a real email account? Like one of those that I virtual host.


I assume, that POSTFIX is your local MTA. Thus the following should solve your problem:

echo "yourdestination@domain.com" > $HOME/.forward


| improve this answer | |
  • This supposes that the addresses correspond to actual local accounts - which does not seem to be the case, since the poster mentiones virtually hosted domains. – Jenny D Feb 18 '14 at 11:29
  • no... you can use any email address in the .forward file. just like someaccount@gmail.com - i used this many times in the past. – Wolfie Feb 18 '14 at 18:10
  • You misunderstand me. The address where the .forward file lives must be a local account on the server. – Jenny D Feb 19 '14 at 6:42
  • maybe i did... but i read the OPs question in the way that he wants exactly that: to have the local account's email forwarded to a virtual mailbox :) – Wolfie Feb 21 '14 at 23:18
  • Yep Wolfie is right, Maybe next time I'll make shorter questions. – Pablo Recalde Feb 22 '14 at 15:28

Postfix has a feature to connect a virtual domain to a particular user. It's described in the virtual readme. Here's a short step-by-step guide:

Add the following lines to /etc/postfix/main.cf

virtual_alias_domains = example.com second.example.com
virtual_alias_maps = hash:/etc/postfix/virtual

Edit /etc/postfix/virtual and add a mapping for each domain to a username

# one address in example.com goes to a specific address
postmaster@example.com   postmaster
# all other addresses in example.com go to oneuser
@example.com             oneuser
# all addresses in second.example.com go to seconduser
@second.example.com      seconduser

Once you've finished this, do the following:

postmap /etc/postfix/virtual
postfix reload

Whenever you add a domain or change a forwarding, just /etc/postfix/virtual and do postmap /etc/postfix/virtual again.

| improve this answer | |
  • I'm sorry that maybe I didn't explained well, so You've interpreted my question backwards, Wolfie's hint is doing great what I wanted. – Pablo Recalde Feb 22 '14 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.