Hello,
I just joined the list and am rather new to Perl in general. I have written
a script that seems to be error free but there is a problem.
The e-mail is sent with the From line of $from and the To line of $to.
Here is the script... can anyone tell me why this isn't working properly?
Thanks in advance...
&get_form_data;
&send_mail;
&print_thankyou_page;
sub get_form_data
{
#Get the input
read(STDIN, $buffer, $ENV{ 'CONTENT_LENGTH' });
# Split the name-value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
#Un-Webify plus signs and %-encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
$FORM{$name} = $value;
}
}
sub send_mail
{
$to = "$FORM{'to'}";
$from = "$FORM{'from'}";
$subject = "$FORM{'subject'}";
$body = "$FORM{'body'}";
use Net::SMTP;
$smtp = Net::SMTP->new('mail.xxxxxxxx.com'); # connect to an SMTP
server
$smtp->mail( '$from' ); # use the sender's address here
$smtp->to('$to'); # recipient's address
$smtp->data(); # Start the mail
# Send the header.
$smtp->datasend("To: $to\n");
$smtp->datasend("From: $from\n");
$smtp->datasend("Subject: $subject\n");
$smtp->datasend("\n");
# Send the body.
$smtp->datasend("$FORM{'body'}\n");
$smtp->dataend(); # Finish sending the mail
$smtp->quit; # Close the SMTP connection
}
sub print_thankyou_page
{
print "Content-type: text/html\n\n";
print "<HTML>\n<HEAD>\n<BODY>\n</HEAD>";
print "Thanks\n";
print "<A HREF=\"somepage.html\">to somewhere\n";
}
print "</BODY></HTML>";
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
_______________________________________________
Perl-Unix-Users mailing list. To unsubscribe go to
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users