From: "Frank Reid" on
Scenario: I would like to deliver all mail for the @example.com domain to a
single mailbox as a single delivery (to preserve header information). I
have set up:

-- main.cf
virtual_alias_domains = example.com
virtual_alias_maps = hash:/etc/postfix/virtual

-- virtual
@example.com mailbox(a)mydomain.com

This works fine, and all @example.com mail goes to mailbox(a)mydomain.com.
(The mailbox is a Dovecot mailbox, if that matters.)

The problem is that I get a separate copy for every user under @example.com
to the other mailbox. For example, if the original mail is addressed to
user1(a)example.com and user2(a)example.com, I will receive two copies in
mailbox(a)mydomain.com.

Is it possible to consolidate into a single delivery using this method?
I've looked at address rewrite, but I would like to keep the original header
intact showing the intended recipients, if that's possible.

From: Wietse Venema on
Frank Reid:
> Scenario: I would like to deliver all mail for the @example.com domain to a
> single mailbox as a single delivery (to preserve header information). I
> have set up:
>
> -- main.cf
> virtual_alias_domains = example.com
> virtual_alias_maps = hash:/etc/postfix/virtual
>
> -- virtual
> @example.com mailbox(a)mydomain.com
>
> This works fine, and all @example.com mail goes to mailbox(a)mydomain.com.
> (The mailbox is a Dovecot mailbox, if that matters.)
>
> The problem is that I get a separate copy for every user under @example.com
> to the other mailbox. For example, if the original mail is addressed to
> user1(a)example.com and user2(a)example.com, I will receive two copies in
> mailbox(a)mydomain.com.

By default, Postfix makes one delivery per original recipient.
Some organizations receive all their mail in a single mailbox, and
need to split out the mail after dowloading it with fetchmail etc.

(For this, the delivery agent meeds to be configured to prepend an
X-Original-To: header with the original recipient address. This is
the default with Postfix's built-in mailbox delivery agents, but
needs to be configured explicitly when using an external mailbox
delivery agent such as Dovecot.)

> Is it possible to consolidate into a single delivery using this method?
> I've looked at address rewrite, but I would like to keep the original header
> intact showing the intended recipients, if that's possible.

Yes it is possible. However, I need to warn you first about a
mis-conception.

The To: header is NOT a reliable indicator of the intended recipient.

For example, this message is sent To: postfix-users(a)postfix.org,
yet it arrives in your mailbox. It would be a mistake to make mail
delivery decisions based on the information in the To: header.

To turn off the original recipient logic in virtual aliases, see
http://www.postfix.org/postconf.5.html#enable_original_recipient

Wietse

From: "Frank Reid" on
Wietse Venema wrote:

> Yes it is possible. However, I need to warn you first about a
> mis-conception.

> The To: header is NOT a reliable indicator of the intended recipient.

Understand. I have no intention to sort out or deliver this mail by other
means from the destination mailbox. It's for a demonstration to show how
discrete recipients would have been originally addressed from a remote
system. When the system is ready, I will remove the virtual_alias_maps and
let it talk directly to the real destination.

> To turn off the original recipient logic in virtual aliases, see
> http://www.postfix.org/postconf.5.html#enable_original_recipient

I have set "enable_original_recipient = no" in main.cf and confirmed with
postconf -n. Still, it does not control this behavior, and I receive a
unique copy of the mail for each recipient originally addressed under the
virtual_alias_domain. I have tried to deliver to a non-Dovecot (remote)
mailbox with the same results.

mail_version = 2.3.3

Any thoughts?

From: Wietse Venema on
Frank Reid:
> Wietse Venema wrote:
>
> > Yes it is possible. However, I need to warn you first about a
> > mis-conception.
>
> > The To: header is NOT a reliable indicator of the intended recipient.
>
> Understand. I have no intention to sort out or deliver this mail by other
> means from the destination mailbox. It's for a demonstration to show how
> discrete recipients would have been originally addressed from a remote
> system. When the system is ready, I will remove the virtual_alias_maps and
> let it talk directly to the real destination.
>
> > To turn off the original recipient logic in virtual aliases, see
> > http://www.postfix.org/postconf.5.html#enable_original_recipient
>
> I have set "enable_original_recipient = no" in main.cf and confirmed with
> postconf -n. Still, it does not control this behavior, and I receive a
> unique copy of the mail for each recipient originally addressed under the
> virtual_alias_domain. I have tried to deliver to a non-Dovecot (remote)
> mailbox with the same results.
>
> mail_version = 2.3.3

To prove that POSTFIX is at fault you need to demonstrate that
ONE message with MULTIPLE recipients results in MULTIPLE deliveries.

Wietse

From: "Frank Reid" on
Wietse Venema wrote:

> To prove that POSTFIX is at fault you need to demonstrate that
> ONE message with MULTIPLE recipients results in MULTIPLE deliveries.

I did some tests, and it appears it only happens when addressing the virtual
domain. POSTFIX does only one "RCPT TO" for normal (local or remote)
domains, but for the virtual domain, it does a "RCPT TO" for each recipient
under the virtual domain that's destined.

Again, configuration for reference:

-- main.cf
virtual_alias_domains = example.com
virtual_alias_maps = hash:/etc/postfix/virtual

-- virtual
@example.com mailbox(a)mydomain.com

Below is the transcript from a remote mail server (MDaemon) that receives
"mailbox(a)mydomain.com" mail. Note that POSTFIX generated a new "RCPT TO"
for the same mailbox for each time a user was addressed in under the virtual
domain, e.g. 20 users under @example.com would equal 20 RCPT TO.

Sun 2010-03-28 14:48:54: <-- MAIL FROM:<remote-user(a)anotherdomain.com>
SIZE=666
Sun 2010-03-28 14:48:54: --> 250 <remote-user(a)anotherdomain.com>, Sender ok
Sun 2010-03-28 14:48:54: <-- RCPT TO:<mailbox(a)mydomain.com>
Sun 2010-03-28 14:48:54: --> 250 <mailbox(a)mydomain.com>, Recipient ok
Sun 2010-03-28 14:48:54: <-- RCPT TO:<mailbox(a)mydomain.com>
Sun 2010-03-28 14:48:54: --> 250 <mailbox(a)mydomain.com>, Recipient ok
Sun 2010-03-28 14:48:54: <-- DATA
Sun 2010-03-28 14:48:54: Creating temp file (SMTP):
c:\mdaemon\temp\md50000001288.tmp
Sun 2010-03-28 14:48:54: --> 354 Enter mail, end with <CRLF>.<CRLF>
Sun 2010-03-28 14:48:54: Message size: 666 bytes
Sun 2010-03-28 14:48:54: Message creation successful:
c:\mdaemon\inbound\md50000315611.msg
Sun 2010-03-28 14:48:54: --> 250 Ok, message saved <Message-ID:
016f01cacea7$47cd2f10$d7678d30$@fleetcenter(a)gcs.frad.org>
Sun 2010-03-28 14:48:54: <-- QUIT

I'm certain it's something I'm doing wrong, but I appreciate any help
locating it. Thanks.