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__

Regards,
Edward

In reply to Re^2: CGI form to email - with mailx? by monkfan
in thread CGI form to email by ezekiel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.