Dear davido,
I am sorry to have to intrude you back again after
this wonderful old post of yours.
First of all can you enable the above script again from your server?
Since when I tried it here, it gave error.
I think because it fail to recognize this line:
my ( $tof_file, $bof_file ) = ( '', '../site_templates/bof.shtml' );
I have the similar problem with OP.
The following script does a simple
processing. It try to send the input values by email.
Initially with "mailx" command under linux,
then with Mail::Mailer as you suggested.
But why my script below fail to send the email?
The script below also accessible in the following
site:
__BEGIN__
#!/usr/bin/perl -wT
use CGI ':standard';
use Data::Dumper;
print header, start_html('Order Ice Cream with Price'),
h1('Order Ice Cream with Price');
generate_form();
print_results() if param();
print end_html();
sub print_results {
print b('Customer name: '), param('customer'), br;
my $ct = param('cone');
my $nu = param('no_unit');
my $uemail = param('user_email');
my $subject = "Result";
if ( $ct && $nu ) {
my $content = "You ordered $ct as many as $nu unit";
print $content,br;
print "This message should be sent to your email address: ",u(
+$uemail), " soon";
# Tried to send email here, but fail...
# system("mailx -s $subject $uemail < $content");
# Tried this to send email also fail...
# It says can't find module, but in my server
# I have no problem doing: perl -c mailresult.cgi
send_message( $uemail, "monkfan",
"ewijaya\@i2r.a-star.edu.sg", $subject,
$content );
}
else {
show_error_message();
}
}
sub send_message {
# I deliberately remove $q here
my ( $recipient_addr, $sender_name, $sender_email, $subject,
$message )
= @_;
my $mail = new Mail::Mailer;
$mail->open(
{ To => $recipient_addr,
From => $sender_email,
Subject => "[Perlmonk Contact] " . $subject
}
)
or die "Can't open mail transport system: $!\n";
print $mail $message;
close $mail or die "Can't close mail transport session: $!\n";
}
sub show_error_message {
print "Unit Too Large\n";
}
sub generate_form {
print hr, start_form,
strong('Your name : '),
textfield( -name => 'customer' ), br,br
strong('Your email: '),
textfield( -name => 'user_email'), br,br
strong('Cone: '),
radio_group( -name => 'cone', -multiple => 1,
-values => [qw/sugar waffle/]),br,br
strong('Number of Units: '),
textfield( -name => 'no_unit'), br,br
submit( -value => 'Send Order' ),
end_form, hr;
}
__END__
|