#!/usr/bin/perl use Modern::Perl; use Mail::Sendmail; # required to use the Mail::Sendmail library use CGI qw/:standard/; use CGI::Carp qw/fatalsToBrowser/; print header(), start_html(); my $check = 0; my $mailTo = param('toaddr'); if ($mailTo ~~ /^\s*$/) { print p ("You need a valid to address."); $check++; } my $mailFrom = param('fromaddr'); if ($mailFrom ~~ /^\s*$/) { print p ("You need a valid from address."); $check++; } my $subjectLine = param('subject'); if ($subjectLine ~~ /^\s*$/) { print p ("You need to enter a subject."); $check++; } my $message = param('message'); if ($message ~~ /^\s*$/) { print p ("You need to enter a message."); $check++; } if ($check == 0) { my %mail = ( To => $mailTo, From => $mailFrom, Subject => $subjectLine, Message => $message, # must be a string, not an array 'Content-Type' => 'text/plain' ); if ( sendmail %mail ) { print p ("Successfully sent mail to $mailTo from $mailFrom. Check your box!\n"); } else { print p ("Error sending mail: $Mail::Sendmail::error \n"); } } else { print a ({ -href=>'javascript:history.back();' }, "Go back and fill in everything!" ); } print end_html();