The source code of mail.pl :
#!/usr/bin/perl
# Demo call of sendmail to be used a CGI script
# Author: R Bland August 2001, with minor edits by SBJ
# Important points:
#
# 1) The script must _run_ on a server offering a sendmail command.
# Use the script's filename as a URL in a browser or WWW form,
# as (for example)
# http://shark.cs.stir.ac.uk/~abc01/mailrbl.pl
# 2) As it stands, this script must be customized with the sender's
# and receiver's email addresses - of course any of these could be
# obtained from CGI parameters.
# 3) This facility can easily be used to send unwanted mail.
# You must not do this. Your scripts must be carefully and
# responsibly written.
# 4) As part of responsible use, you should make sure that the
# user of one of your WWW forms cannot type-in data that will
# cause unwanted mail to be sent.
use strict ;
# HTTP Header for the server: note two newlines
print "Content-type: text/html\n\n" ;
# HTML header for the browser
print "\n" ;
print "\n" ;
print " \n" ;
print " sendmail from Perl\n" ;
print " \n" ;
print " \n" ;
print " sendmail from Perl
\n" ;
my $sender = '???' ; # eg 'abc'
my $receiverName = '???' ; # eg 'def'
my $receiverAddress = '??????' ; # eg 'cs.stir.ac.uk'
my $replyName = '???' ; # eg 'abc'
my $replyAddress = '???????' ; # eg 'students.stir.ac.uk' (if that's abc's email server)
print "Mailing $receiverName\@$receiverAddress ...
\n" ;
# We have three parts: $command, $flags, $message
# First, the command
my $command = "/usr/sbin/sendmail" ;
#
# Now the flags:
# -t specifies that To: etc are read from the message
my $flags = "-t" ;
#
# The message is a single string. It contains
# multiple lines enclosed in the lines
# "<\n", $rc ;
print "If the return code was 0000, then the message "
."should be on its way to "
."$receiverName\@$receiverAddress...
\n" ;
print "... finished
\n" ;
print " \n" ;
print "\n" ;