CGI (Perl) - SMTP & Rediret Method
Good day !
I have written the codes below and try to execute it. Theoritically, I suppose it works but it doesn't. I can't figure out what's wrong with my codes.
The 2 problems are :
1) It supposed to send back a mail to me but it doesn't. I used the code from Deitel & Deitel text book.
2) It doesn't redirect to the page "default.asp" after executing the commands. May be I had put the code at the wrong place ?
Anybody can look at my code and tell me what's wrong ?
Thanks a lot !
--------------------------------------------------------------------------------
use Net::SMTP;
use CGI qw/:standard/;
my $to = "[email protected]";
my $from = "[email protected]";
my $subject = param ("SelectPurpose");
my $message = param ("TxtMessage");
my $mailserver = "hotmail.com";
print header;
print "<p>Your message has been sent !";
print "Thank you for your contribution !";
$smtp = Net::SMTP->new($mailserver);
$smtp->mail($ENV{USER});
$smtp->to("$to");
$smtp->data();
$smtp->datasend("To : $to \n");
$smtp->datasend("From : $from \n");
$smtp->datasend("Subject: $subject \n");
$smtp->datasend("\n");
$smtp->datasend("$message \n");
$smtp->datasend();
$smtp->quit;
print redirect('../default.asp');
-----------------------------------------------------------------------------
Thanks again !
SonicWave :p
Will the procedures after "Redirect" Will Be Executed ?
Good day !
I not sure whether Hotmail.com can be used or not, but that's what my tutor told me. I also confused.
Besides, about "redirect". if I put it in the front, will the other functions / procedures after it will be executed ?
If cannot , what should I do to modify my program so that, it will first have all functions executed, then only redirect to another page ?
Thanks a lot !
SonicWave :p