Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello guys, and gals

I'm using the following code, for a simple cgi routine, and would like the ability to send the contents via E-Mail.

#!/perl/bin/perl.exe -T use CGI; use strict; use warnings; my $q = new CGI; my $company = $q->param('company'); my $last = $q->param('last'); my $first = $q->param('first'); my $serial = $q->param('serial'); my $meter = $q->param('meter'); print $q->header("text/HTML"); print <<WEB_PAGE; <HTML> <HEAD> <TITLE>Test CGI</TITLE> </HEAD> <BODY> <H3>You Entered</H3><BR> <PRE> WEB_PAGE &INFO; print "\<\/PRE\>\n"; print "\<\/BODY\>\n"; sub INFO { print "COMPANY: $company\n"; print "LAST: $last\n"; print "FIRST: $first\n"; print "SERIAL: $serial\n"; print "METER: $meter\n"; }
Is there a simple way to do that?

Thanks

Replies are listed 'Best First'.
Re: sending E-Mail via CGI
by waswas-fng (Curate) on Dec 23, 2002 at 23:01 UTC
Re: Sending Email Via CGI
by cjf-II (Monk) on Dec 23, 2002 at 23:26 UTC
Re: sending E-Mail via CGI
by tachyon (Chancellor) on Dec 24, 2002 at 05:46 UTC

    If sendmail is available (very likely) you can just:

    # path to sendmail needs to be correct, this is a good guess $mail_prog = '/usr/lib/sendmail' ; open MAIL, "|$mail_prog -t" or die "Can't open pipe to $mail_prog, rea +son $!\n" print <<MAIL; To: $recipient Reply-to: $reply_to From: $from Subject: $subject $body MAIL close MAIL;

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print