in reply to How do I send mail from a script?

Nickd_69,
Ok - I am likely going to receive some downvotes for being so harsh with you, but so be it. It doesn't appear that you are even beginning to make an effort here. In Premature end of script headers you asked this very question. I gave you advice here, and provided more advice as well as code here and here. You didn't take my advice nor did you come back to say what errors you ran into. So let me break it down step by step.
#!/usr/bin/perl -w # This turns on warnings use strict; # This pragma will help you avoid common mistakes by enforcing commonl +y accepted "good" coding techniques use CGI; # This will allow you to redirect your web page once you send the emai +l use CGI::Carp qw(fatalsToBrowser); # This will put any fatal errors to your web page instead of to the no +rmal error log use Mail::Mailer; # This will allow you to send the email my $query = CGI->new(); # This creates a new CGI object. The redirect method will come after +we have sent the mail. my %DATA = $query->Vars; # This uses a method on the CGI object to stick all the form values i +nto the DATA hash for you my $mailer = new Mail::Mailer ( "smtp" ); $mailer->open( { To => 'info@travancoresch.vic.edu.au', From => $DATA{Email}, Subject => 'Travancore School Professional Development' } ); # This will create a new object that we will use to send the email print $mailer "$DATA{Att1}\n"; print $mailer "$DATA{Att2}\n"; print $mailer "$DATA{Att3}\n"; # This will print to the email $mailer which is a file handle created +for you when you create the object. $mailer->close; # This sends the email print $query->redirect('http://www.travancoresch.vic.edu.au/developmen +t/reply02.html'); # This redirects the web page to the new desired location
I am going to suggest you read the past replies I have sent to actually look at the comments I made and not just blindly copy and paste code. You have repeated the same mistakes.

If you do all that and it still doesn't work - come back and tell us what errors you got - we will be glad to help.

L~R

Replies are listed 'Best First'.
Re: Re: How do I send mail from a script?
by Nickd_69 (Novice) on Aug 13, 2003 at 00:39 UTC
    Look I'm sorry for getting you so pissed off but I am only learning. I have gone through your code and I had already read all your comments and nearly all available info off this site. I now have the following script but the error I get in my error log is something like that CGI is not declared on line 8 and the script was aborted due to compilation errors. Could you just have a quick look? I know how frustrating newbies are but im slowly getting it!!
    #!/usr/bin/perl -w use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); use Mail::Mailer; my $query = CGI->new(); my %DATA = $query->Vars; my $mailer = new Mail::Mailer ( "smtp" ); $mailer->open( { To => 'info@travancoresch.vic.edu.au', From => $DATA{Email}, Subject => 'Travancore School Professional Development' } ); print $mailer "$DATA{Title}\n"; print $mailer "$DATA{Name}\n"; print $mailer "$DATA{Position}\n"; print $mailer "$DATA{School}\n"; print $mailer "$DATA{Address}\n"; print $mailer "$DATA{Suburb}\n"; print $mailer "$DATA{State}\n"; print $mailer "$DATA{PCode}\n"; print $mailer "$DATA{Email}\n"; print $mailer "$DATA{Tel}\n"; print $mailer "$DATA{Fax}\n"; print $mailer "$DATA{Att1}\n"; print $mailer "$DATA{Att2}\n"; print $mailer "$DATA{Att3}\n"; $mailer->close; print $query->redirect('http://www.travancoresch.vic.edu.au/developmen +t/reply02.html');