>I'm currently writing a mail-alias system "� la" iname.com (but just for
>a few domains), and I am asking myself which is the best way to do it. ...
>Isn't it possible to let qmail look in a file looking like
>this : ?
>---------
>user1 [EMAIL PROTECTED]
>user2 [EMAIL PROTECTED]
>...
Sure. There are a couple of ways to do this. If you know you'll just
be forwarding the mail without inspecting or changing it, deliver all
of the mail for a domain like this:
~MAILDOMAIN/.qmail-default would contain:
| forward `lookup-address MAILDOMAIN "$DEFAULT"`
You provide a little lookup-address program that takes the virtual domain
and address as arguments and writes the forwarding address to its stdout.
Qmail will do the rest and forward it along.
If you want to do something fancier, deliver your mail to a program and have
it remail it. That's what I do for abuse.net. For example:
~MAILDOMAIN/.qmail-default would contain:
| deliver-virtual-mail MAILDOMAIN "$DEFAULT"
Now the program deliver-virtual-mail gets the domain and username as
arguments and can read the incoming mail as the standard input. It
calls qmail-queue to remail the message. Here's the skeleton of a
perl script to remail stuff with a tag at the bottom. A real version
would do some logging and error checking.
# remailer
$vdomain = shift; $vuser = shift; # command line arguments
$realaddress = &lookup($vdomain, $vuser); # consult database or something
# run qmail-queue to remail the message, use envelope from of virtual
# user because we remailed it
open(MAIL, "|-") ||
exec ("/var/qmail/bin/qmail-inject", "-a", "-f$vuser\@$vdomain",
$realaddress);
while(<>) { # pass through message
print MAIL $_;
}
# add tag at the end
print MAIL "--\nForwarded by the Most Excellent Mail Forwarding Service.\n"
close(MAIL);
exit 0;
--
John R. Levine, IECC, POB 727, Trumansburg NY 14886 +1 607 387 6869
[EMAIL PROTECTED], Village Trustee and Sewer Commissioner, http://iecc.com/johnl,
Member, Provisional board, Coalition Against Unsolicited Commercial E-mail