[svlug] Aliased emails ala craigslist?

Seth David Schoen schoen at loyalty.org
Thu Apr 27 18:39:31 PDT 2006

To underscore the point that I didn't test my handler code, it has
an unbalanced quote.  It won't run at all.

So, write your own handler that parses the message fed to it on
standard input, extracts the necessary information from the
headers, and forwards the body to the proper recipient.  And call
that handler from the MDA.

For example, one way of setting up a wildcard delivery using Postfix

# in /etc/postfix/main.cf
virtual_alias_domains = grumblenet.net
virtual_alias_maps = hash:/etc/postfix/virtual

# in /etc/postfix/virtual (run postmap virtual after changing)
@grumblenet.net	mumble

# in /etc/aliases (run newaliases after changing)
mumble: |/usr/local/bin/grumble-handler

The result of all of this is that if you send any mail to any
address at grumblenet.net, it will get fed to the standard input
of the process /usr/local/bin/grumble-handler.  That program
could then parse the message to figure out whom to forward the
mail to, by looking up the receipient in a database.

There is also a way to make Postfix directly query an address
translation database, which could imply that you wouldn't even
need to write a grumble-handler at all -- you could just tell
Postfix to use the database and then forward the mail to the
appropriate party.  (I think you could just use a database as
the target of virtual_alias_maps; consult the documentation.)
There are drawbacks to this.  For example, it might result in
people who send mail to aliases seeing bounces directly if
there are any delivery problems at the recipient's end.  Someone
might write to foo-12387197 at grumblenet.net and then get a bounce
from john.public at mumblecom.com indicating that John Public's
mailbox was full.  Then the sender would know John Public's
identity.  That would seem to argue for generating your own
message containing the contents of the message you want to forward.

Seth David Schoen <schoen at loyalty.org> | This is a new focus for the security
     http://www.loyalty.org/~schoen/   | community. The actual user of the PC
     http://vitanuova.loyalty.org/     | [...] is the enemy.
                                       |          -- David Aucsmith, IDF 1999

More information about the svlug mailing list