#!/usr/bin/perl
use CGI qw(:standard);
use CGI::Carp qw/ fatalsToBrowser /; # remove for production
#Talk directly to sendmail, not using Mail::Sendmail
$SENDMAIL_CMD = '|/usr/lib/sendmail -t -oi';
$cgi = new CGI;
print $cgi->header;
sub getData{
#get form data, $query->Vars();
}
sub validate{
if (keys %errors){
while ( ($key, $value) = each %errors){
print $cgi->p("$key, $value\n");
}
&displayErrorPage;
}else{
&sendEmail;
&displayConfirmationPage;
}
}
sub sendEmail{
$emailBody = $emailBody . "EMAIL TEXT";
%mail = (
SMTP => 'localhost',
from => 'from address', #userEmail
to => "TO <$emailAddress>",
cc => "CC ",
bcc => "Developer ",
subject => "Subject Line",
);
$boundary = "====" . time() . "====";
$mail{'content-type'} = "TEXT/plain; boundary=\"$boundary\"";
$boundary = '--'.$boundary;
$mail{body} = $mail{body} . $emailBody;
sendmail(%mail);
}
sub displayErrorPage{ print $cgi->h1("Errors were present"); }
sub displayConfirmationPage{
print $cgi->p("Thank You -- blah blah blah.");
}
sub sendmail{
my(%mail)= @_;
open(MF, $SENDMAIL_CMD) || print "Sendmail Error! ($!)\n";;
print MF<<__MAIL_EOF__;
From: $mail{from}
To: $mail{to}
Bcc: $mail{bcc}
Subject: $mail{subject}
$mail{body}
__MAIL_EOF__
}