#! /usr/bin/perl -w

#   cgi41_email.pl
#   How to access a Unix_Linux command (non_GUI one but command line one) in PERL?
#   Please use open with Process_Handle
#
#    open (PROC_HANDLE, | unix_command );
#
#   This is very similar to the text file opening.  
#   Name Process_Handle as you like.  Below, it is named MAIL.
#   The below is taken from an actual sample, so it isn't simplified enough for this topic.
#   Hope you will get an idea.
#



#   The following two parameter capture (topic and message) is beyond the scope 
#   of this Unix_Linux command access example.   Just take it lightly that 
#   there is a way to set the varaibles (topic, message) by parameter capture
#   from preceding activities.

use CGI qw(:param);

$topic   = param("topic");
$message = param("message");



##  Set various variables here.
$recipient='username@aol.com';
$from=     'username@server.net';
$subject=  'SENDING EMAIL FROM SERVER';


##  Set up the whole Email.
##  Here! Here!   HOW TO ACCESS Unix_Linux command sendmail by open.

open (MAIL, "| /usr/sbin/sendmail -t ") || die $!;
print MAIL "To: $recipient\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n";
print MAIL "I want to chat about $topic.\n";
print MAIL "Message is,\n";
print MAIL "$message\n";
close (MAIL);

## End of send email