|
-
Mar 13th, 2002, 11:47 AM
#1
Thread Starter
Lively Member
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
-
Mar 13th, 2002, 11:57 AM
#2
Black Cat
1. Is hotmail.com a SMTP server that will accept connections from random ip addresses?
2. You redirect with the HTTP headers, which need to be written before any HTML, so call the redirect first and don't bother printing the confimation message as they generally won't see it.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Mar 13th, 2002, 12:57 PM
#3
Thread Starter
Lively Member
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
-
Mar 13th, 2002, 01:10 PM
#4
Black Cat
What the redirect is going to do is the same as going
Code:
print "Location: somepage.asp\n";
just writing the correct HTTP header to standard output. So you can use all functions etc, but you have to write the HTTP headers first, then the HTML, etc, with the print statement, since anything "print"ed is being written to the web browser. Stuff that doesn't write to the web browser can go anywhere.
Josh
Get these: Mozilla Opera OpenBSD
I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.
-
Mar 13th, 2002, 08:12 PM
#5
Thread Starter
Lively Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|