关于Postfix虚拟域的相关释疑

12/3/2006来源:Qmail人气:8891

在Postfix 1.1.x中,virtual_maps及virtual_mailbox_maps容易搞混,而在未来的Postfix 2.x中,virtual_*相关的设置也会有所变动。因此有必要搞清楚两者之间的区别和联系,以及虚拟域在Postfix中的实现和相关含义。

寄件者:"James T. Richardson, Jr." ([email protected])
主旨:Postifix %26amp; Virtual Domains


View this article only
新闻群组:mailing.postfix.users
日期:2002-11-26 15:12:06 PST


After setting up Postfix + MySQL I'm having a hard time getting "virtual
aliases" working.

I'm wanting to use Virtual Mailbox Domains (not Postfix-Style, nor
Sendmail-Style).

Mail is delivered to both my local domain and to my virtual domains. At
least for my users that have Maildir's defined.

Relevant sectionof the config:
---
myhostname = mail-gateway.mydomain.com
myorigin = $mydomain
mydestination = $myhostname, localhost.$mydomain $mydomain
local_recipient_maps = $alias_maps unix:passwd.byname
alias_maps = hash:/etc/postfix/aliases
alias_database = $alias_maps
transport_maps = mysql:/etc/postfix/transport.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virt.cf
hash:/etc/postfix/virtual
virtual_uid_maps = mysql:/etc/postfix/uids.cf
virtual_gid_maps = mysql:/etc/postfix/gids.cf
virtual_mailbox_base = /var/mail/vhosts
---

The "mysql_virt.cf" file looks like:
user=postfix
passWord=sekret
dbname=maildb
table=users
select_field_maildir
where_field=address
hosts=localhost

Following instructions by Victor Duchovni
(http://groups.google.com/groups?hl=en%26amp;lr=%26amp;ie=UTF-8%26amp;oe=UTF-8%26amp;selm=ajh5mv
[email protected]%26amp;rnum=1):

> I call such domains *virtual-mailbox* domains. To define a virtual-mailbox
> domain, just a "domain whatever" entry to one of the tables listed in
> $virtual_mailbox_maps. For now it is also necessary to add the domain to
> the transport table in order to arrange for mail to the domain to be
> handled by a suitable virtual delivery agent (PResumably but not
> necessarily the Postfix "virtual" delivery agent).

I created a simple hash (for now) files of "domain whatever" (and ran
postmap on it) and stuck it on the end of virtual_mailbox_maps.

Now, I'm not sure where to create these aliases or where to tell Postfix
about them. I tried putting an alias to [email protected] underneath the
"domain whatever" line in the virtual file, but that didn't work. I got
a
To=, relay=virtual, delay=0, status=deferred
(recipient [email protected]: uid not found in virtual_uid_maps)

Surely my aliases don't need assciated UID/GID's? do they?

---

James T. Richardson, Jr.
[email protected]
Post a follow-up to this message

Message 2 in thread
寄件者:Russell Mosemann ([email protected])
主旨:Re: Postifix %26amp; Virtual Domains


View this article only
新闻群组:mailing.postfix.users
日期:2002-11-26 15:33:51 PST


On Tue, 26 Nov 2002, James T. Richardson, Jr. wrote:

> After setting up Postfix + MySQL I'm having a hard time getting "virtual
> aliases" working.
>
> I'm wanting to use Virtual Mailbox Domains (not Postfix-Style, nor
> Sendmail-Style).
>
> Mail is delivered to both my local domain and to my virtual domains. At
> least for my users that have Maildir's defined.
>
>
> Relevant sectionof the config:
> ---
> myhostname = mail-gateway.mydomain.com
> myorigin = $mydomain
> mydestination = $myhostname, localhost.$mydomain $mydomain
> local_recipient_maps = $alias_maps unix:passwd.byname
> alias_maps = hash:/etc/postfix/aliases
> alias_database = $alias_maps
> transport_maps = mysql:/etc/postfix/transport.cf
> virtual_mailbox_maps = mysql:/etc/postfix/mysql_virt.cf
> hash:/etc/postfix/virtual
> virtual_uid_maps = mysql:/etc/postfix/uids.cf
> virtual_gid_maps = mysql:/etc/postfix/gids.cf
> virtual_mailbox_base = /var/mail/vhosts
> ---
>
> The "mysql_virt.cf" file looks like:
> user=postfix
> password=sekret
> dbname=maildb
> table=users
> select_field_maildir
> where_field=address
> hosts=localhost
>
> Following instructions by Victor Duchovni
> (http://groups.google.com/groups?hl=en%26amp;lr=%26amp;ie=UTF-8%26amp;oe=UTF-8%26amp;selm=ajh5mv
> [email protected]%26amp;rnum=1):
>
> > I call such domains *virtual-mailbox* domains. To define a virtual-mailbox
> > domain, just a "domain whatever" entry to one of the tables listed in
> > $virtual_mailbox_maps. For now it is also necessary to add the domain to
> > the transport table in order to arrange for mail to the domain to be
> > handled by a suitable virtual delivery agent (presumably but not
> > necessarily the Postfix "virtual" delivery agent).
>
> I created a simple hash (for now) files of "domain whatever" (and ran
> postmap on it) and stuck it on the end of virtual_mailbox_maps.
>
> Now, I'm not sure where to create these aliases or where to tell Postfix
> about them. I tried putting an alias to [email protected] underneath the
> "domain whatever" line in the virtual file, but that didn't work. I got
> a
> To=, relay=virtual, delay=0, status=deferred
> (recipient [email protected]: uid not found in virtual_uid_maps)
>
> Surely my aliases don't need assciated UID/GID's? do they?

I don't think you read Victor's message very carefully. A virtual domain
is different from a virtual mailbox domain. virtual_maps are used not
only for redirecting email from one address to one or more other
addresses, it is also used for virtual domains. virtual_mailbox_maps are
used for virtual mailbox domains and for mailboxes on the local computer
that do not have an associated Unix account. You are mixing the two, and
that is the cause of your problems.

----
Russell Mosemann, Ph.D. * Computing Services * Concordia University, Nebraska
"A penny saved is a penny earned." "Penny wise, pound foolish."
Post a follow-up to this message

Message 3 in thread
寄件者:[email protected] ([email protected])
主旨:Re: Postifix %26amp; Virtual Domains


View this article only
新闻群组:mailing.postfix.users
日期:2002-11-26 19:12:51 PST


On Tue, 26 Nov 2002, James T. Richardson, Jr. wrote:

> Following instructions by Victor Duchovni
> (http://groups.google.com/groups?hl=en%26amp;lr=%26amp;ie=UTF-8%26amp;oe=UTF-8%26amp;selm=ajh5mv
> [email protected]%26amp;rnum=1):
>
> > I call such domains *virtual-mailbox* domains. To define a virtual-mailbox
> > domain, just a "domain whatever" entry to one of the tables listed in
> > $virtual_mailbox_maps. For now it is also necessary to add the domain to
> > the transport table in order to arrange for mail to the domain to be
> > handled by a suitable virtual delivery agent (presumably but not
> > necessarily the Postfix "virtual" delivery agent).
>
> I created a simple hash (for now) files of "domain whatever" (and ran
> postmap on it) and stuck it on the end of virtual_mailbox_maps.
>
> Now, I'm not sure where to create these aliases or where to tell Postfix
> about them. I tried putting an alias to [email protected] underneath the
> "domain whatever" line in the virtual file, but that didn't work. I got
> a
> To=, relay=virtual, delay=0, status=deferred
> (recipient [email protected]: uid not found in virtual_uid_maps)
>

You actually searched for and found some documentation and mostly
followed it correctly! You deserve a break.

Your issue is that you are trying to specify address rewriting rules
("aliases" of sorts) for virtual mailbox domains in the
virtual_mailbox_maps tables. These tables define the pathname of the
virtual user's mailbox, not an alternate address.

For virtual mailbox users the only available address rewriting mechanism
is $virtual_maps. Don't put the "domain anything" keys for virtual
mailbox domainsthere, but do put address rewriting rules there.

So

virtual_mailbox_maps = hash:/etc/postfix/vmboxdomains, mysql:mumble
virtual_maps = mysql:fumble

/etc/postfix/vmboxdomains will have all the "domain anything" keys. List
it first, as these lookups will be very fast in comparison to mysql.

mysql:mumble will map virtual users to their mailbox path.
mysql:fumble (or hash:fumble) will map "aliased" virtual users to the
correct email address(es).

--
Viktor.