#!/usr/bin/perl
$mailprog = '/usr/bin/mail';
print "Content-type: text/html\n\n";
print "<HEAD><TITLE>Send mail to the unregister user</TITLE></HEAD>\n";
print "<BODY BGCOLOR=#000000 TEXT=#FFFFFF>\n";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
## Split the name-value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
    ($name, $value) = split(/=/, $pair);
    $value =~ tr/+/ /;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $FORM{$name} = $value;
}
&error unless $FORM{'s_mess'};
open(F,">unreg_temp");
print F $FORM{'s_name'};
close(F);
open(F,"unreg_temp");
print "The messages has been sent to the following address<BR>\n";
while(<F>){
	$recipient = $_;
	print "$recipient<BR>\n";
	open (MAIL, "| /usr/bin/mail -s $recipient ");
	print MAIL "Reply-to: clinton\@tlcplus.com\n";
	print MAIL "Subject: $FORM{'s_sub'}\n\n";
	print MAIL $FORM{'s_mess'};
	close(MAIL);
}
close(F);
sub error{
	print "Sorry please enter the messages";
	exit;
}
