Date: Wed, 05 Mar 2003 12:11:10 +1100
  From: Tom Ryan tom.ryan@whitehorsestrategic.com
  Subject: RE: multiple domains with postfix
  To: luv@luv.asn.au
Adam Clarke wrote:
  > Theng Ung wrote:
  > >I am new to postfix. I manage to get it going with
  two
  > >domains. The problem is though if I send an email to
  > >user1@domain1 or user1@domain2 it arrive at user1
  > >mailbox.
  >
  > I'm afraid that's how it works. What you need to do is give
  each user a
  > different local account and direct their domain specific
  mail there.
  >
  > So user1@domain1 might have an account of user1_d1 (or the
  like) and
  > user1@domain2 might be user1_d2.
Incorrect. You need to use virtual domains. Virtual domains
  take
  precedence over local aliases. Having a local account or alias of
  the same
  name does not interfere with a virtual mapping.
The process is simple. Here is what you need to do:
0. read this whole email before you start ;)
1. main.cf additions
  1a. run "postconf -n" and check that there is a line like:
  virtual_maps = hash:/etc/postfix/virtual
  if not add that line to main.cf
  1b. check that all the domains for which you will receive
  mail are referenced in $mydestination in main.cf
2. the virtual table
  2a. add your virtual aliases to the virtual_maps from main.cf
  in your case use this format:
  user@virtual.domain localuser0
  user@other.domain localuser1
  NOTE: do NOT include a line like:
  virtual.domain ANYTHING
  or you will no longer receive mail to local users not
  mentioned in the virtual file. If you read up on this
  you'll understand why. if you don't... just go along
  with me on this one, and it'll work. ;)
3. use the changes
  3a. restart postfix:
  $ postfix reload
  3b. generate the virtual table hash:
  $ postmap /etc/postfix/virtual
  (or wherever your virtual file is)
NOTES:
the "virtual" equiv of newaliases:
  $ postmap /etc/postfix/virtual
  run that when you update the virtual table.
here's a more complete look at the ways you can map addresses:
----from the openbsd postfix package's virtual(5) man
  page-----
  user@domain address, address, ...
  Mail for user@domain is redirected to address.
  This form has the highest precedence.
user address, address, ...
  Mail for user@site is redirected to address when
  site is equal to $myorigin, when site is listed in
  $mydestination, or when it is listed in
  $inet_interfaces.
This functionality overlaps with functionality of
  the local alias(5) database. The difference is that
  virtual mapping can be applied to non-local
  addresses.
@domain address, address, ...
  Mail for any user in domain is redirected to
  address. This form has the lowest precedence.
In all the above forms, when address has the form @other-
  domain, the result is the same user in otherdomain. This
  works for the first address in the expansion only.
  --------------------------------------
  And that's all the postfix that's fit to print ;)
regards,
  tom ryan.
  Date: Thu, 06 Mar 2003 11:29:42 +1100 (EST)
  From: Theng Ung thengsta@yahoo.com.au
  Subject: more postfix
  To: luv@luv.asn.au
Hello,
Just wondering if anyone can explain about hosting emails for
  differents
  domains on the same postfix server. This question may be for
  people from
  ISP system admin background.
e.g., john@domain1, joe@domain1
  john@domain2, joe@domain2 ....
This should be simple for a couple domain as we can set up
  for
  john@domain1 and john@domain2 go to a particular mailbox. What
  happen if
  there are say 100 domains with similar account?
normally we can access the email for john@domain1 with
  username
  john@domain1 and password and for john@domain2 use username
  john@domain2
  and password.
Regards,
  Theng
Date: Thu, 06 Mar 2003 17:11:22 +1100
  From: Ben McGinnes ben@adversary.org
  Subject: Re: more postfix
  To: luv@luv.asn.au
Theng Ung(thengsta@yahoo.com.au)@Thu, Mar 06, 2003 at 11:29:42AM +1100:
> Just wondering if anyone can explain about hosting emails
  for
  > differents domains on the same postfix server.
Yeah, do-able. You really have to decide, though, whether you
  want to
  go for Sendmail-style or Postfix-style.
The former is ideal if you don't care if the address receives
  an actual
  account on the mail server. Sendmail-style is basically a mapping
  of
  user@hosted.domain to xuser@localhost.
Postfix style is preferable where you do not want addresses at
  the
  virtual domain to have either local addresses or accounts.
  Usually in
  these cases you'll have to point the MTA at an additional
  delivery
  agent, like a POP3 or IMAP service (e.g. Cyrus, Cucipop,
  GNUPopper,
  etc.).
Sendmail-style is usually the easiest for people to get a
  grasp on and
  configure.
Details of how to do both are in the Postfix documentation.
  More often
  than not reading through the commentary in the .cf files,
  including
  those in the samples directory, is enough to get it going.
> This should be simple for a couple domain as we can set
  up for
  > john@domain1 and john@domain2 go to a particular mailbox.
  What happen
  > if there are say 100 domains with similar account?
Same thing, only larger.
In the case of Sendmail-style you don't have to map:
exactuser@virtual.domain to exactuser@localhost
You could, for example, do something like this:
exactuser_virtual.domain to exactuser_virtual.domain@localhost
Or, if you're concerned about the length of usernames, use
  some other
  code for each virtual domain. If you're allocating each
  virtual
  domain a different group ID, rather than assigning a generig one,
  then
  you could use that (e.g. map $USER@virtual.domain to
  $USER_$GID@localhost).
With Postfix-style, since you're not mapping to a local user,
  this is
  not a concern. The issue with this style of account, of course,
  is
  authentication. Without a local user it can't readily utilise
  /etc/passwd and /etc/shadow, thus the need for another
  authentication
  method. Often such methods will be incorporated into the
  delivery
  agent.
Regards,
  Ben