An ugly kludge to add X-Envelope-To: headers for pop mailboxes

Status: it works
Recommendation: use uucp instead

if you insist on using this, then read on:

0. Introduction


	1. postfix
	2. procmail + formail
	3. sudo
	4. a user called "vpop", with disabled password and shell=/bin/false

1.  Postfix setup

1a.  /etc/postfix/

vpop	  unix	-	n	n	-	-	pipe
    flags=F user=vpop argv=/usr/bin/sudo -u $nexthop /usr/lib/postfix/deliver-vpop $nexthop $recipient

1b.  /etc/postfix/transports

for each virtual domain, you will need a line in /etc/postfix/transport.
use the following as an example:

	# 	vpop:
	virtual.domain		vpop:fbloggs
	another.domain		vpop:jblow

a useful and interesting thing to note is that entries in
/etc/postfix/virtual have higher precedence than entries in the
transport file, so you can have some addresses at a domain being
delivered to their own pop box, and the remainder being delivered via
the vpop transport.

1c. /etc/postfix/

just like the 'local' transport, you have to limit the number of
destination recipients which can be delivered at one time. any more than
1 will break the addition of the X-Envelope-To: header, which is the
whole point of this exercise.

vpop_destination_concurrency_limit = 1
vpop_destination_recipient_limit = 1

1d. shell script to deliver the mail to the local mailbox

this is the shell script which is executed by the vpop transport. 

It uses formail to add the X-Envelope-To header, and procmail to do
the final delivery to the user's mailbox.  On a debian system, *all*
MTAs, MDAs, and MUAs use the same NFS-safe locking conventions by strict
policy. other unixes and linux distributions are not as consistent, so
you might have to do your own locking. be careful.

--cut here-- /usr/lib/postfix/deliver-vpop --cut here
#! /bin/sh


ENVTO="X-Envelope-To: $recipient"

cat | \
	/usr/bin/formail -Y -I "$ENVTO" | \
	/usr/bin/procmail -Y -t -d "$nexthop"
--cut here-- /usr/lib/postfix/deliver-vpop --cut here

2.  sudo setup

we need to allow the "vpop" dedicated user run the above shell script as
any user, so add the following lines to /etc/sudoers

Cmnd_Alias VPOP=/usr/lib/postfix/deliver-vpop

3.  Testing

Ok, configuration is done. now restart postfix and send a few test
messages to random addresses at the virtual domain. something like the
following should tell you whether it's working or not:

#! /bin/sh


sendmail -t <<__EOF__
To: foo@$VIRTUAL
Cc: blah@$VIRTUAL
Bcc: secret@$VIRTUAL, very.secret@$VIRTUAL
Subject: test


you should get 4 messages delivered to the virtual pop mailbox, all with
the same To: and CC: headers.  There will be no visible BCC headers, and
each message will have a different X-Envelope-To: header.