#!/usr/bin/perl -wT use strict; use diagnostics; use CGI; use CGI::Carp qw(fatalsToBrowser); use Mail::Sendmail; # Create a new instance of CGI my $query = new CGI; # Send a MIME header to the user's browser print $query->header; # Get the fields from the HTML form my $sender = $query->param("sender"); my $recipient = $query->param("recipient"); my $message = $query->param("message"); # Create the mail message my %mail = (To => $recipient, From => $sender, Message => $message); # Send the message if (sendmail %mail) { # Send some output to the user's browser print $query->start_html(-title => "Success!"); print "<H1>Success!</H1>\n"; print "<P>The following message was " . "successfully sent:</P>\n"; print "<Form method=\"POST\"". action=\"\">\n"; print "<P><HR></P>\n"; print "<P>Sender: $sender</P>\n"; print "<P>Recipient: $recipient</P>\n"; print "<P>Message:<P></P>"; print "<textarea rows=\"20\" cols=\"60\">" . "$message</textarea></P>\n"; print "<P><HR></P>\n"; print "</Form>\n"; print $query->end_html; } else { print "Error sending mail: " . "$Mail::Sendmail::error \n"; }