#!/usr/bin/perl
#
# MailPlex v1.1
# (l) Peter Baudis <pasky@ji.cz> 2001
#
# Modify recepitient's address and give mail to MTA
# Executed for every mail as the last-instance
#
# Parameters: resend.pl <username>
#
# Takes mail from stdin
#

# Configuration:

$sendmail="/usr/sbin/sendmail"; # your sendmail-program equivalent - it shall
				# take raw mail in stdin and rcpt as parameter

#### End of configuration
#### You shouldn't be interested in the rest of file, really, unless you know
#### what are you doing.

use Mail::Internet;
use Mail::Header;

if (!$ARGV[0]) { die "No mail specified!"; }

$msg=new Mail::Internet \*STDIN;

$hdr=$msg->head();
$hdr->replace("To", $ARGV[0]);

open(MAIL, "|$sendmail $ARGV[0]") or die "Cannot pipe to sendmail ($sendmail)!";
$msg->print(\*MAIL);
close(MAIL);
