This is an example showing how to handle HTML::EMBPERL email delivery via an HTML form taken from the EMBPERL site. You may want to add some security checking.
[-
use URI::Escape;
$MailTo = "$fdat{mailto_email}";
$myURI = $fdat{URI};
$name = $fdat{name};
$email = $fdat{email};
$msgtxt = $fdat{msgtxt};
@errors = () ;
if ( defined($fdat{check}) || defined($fdat{send}) )
{
push @errors, "Please enter your name" if (!$fdat{name});
push @errors, "Please enter your e-mail address" if (!$fdat{email});
push @errors, "Please enter friend's name" if (!$fdat{mailto_name});
push @errors, "Please enter friend's email address" if (!$fdat{mailto_email});
push @errors, "Please enter a message" if (!$fdat{msgtxt});
}
-]
[$if (defined($fdat{check}) and $#errors == -1)$]
[- delete $fdat{input} ; delete $fdat{check} ; delete $fdat{send} -]
You have entered the following data. Please confirm and click Send when done.
[$elsif defined($fdat{send}) and $#errors == -1$]
[-
# SET SUBJECT HERE
$subject = "Email from: $name";
# INTRODUCE MSG HERE
$msg = "\n MESSAGE SENT TO YOU FROM $name ($email) \n\n";
# Open The Mail Program - change this to your path for sendmail
$mailprog = '/usr/lib/sendmail';
open(MAIL,"|$mailprog -t");
print MAIL "To: $MailTo\n";
print MAIL "From: nobody\@yourdomain.com\n";
print MAIL "Subject: $subject\n";
print MAIL "\n ========================================================== \n";
print MAIL "$msg";
print MAIL "$msgtxt";
print MAIL "\n ========================================================== \n";
close (MAIL);
-]
Your message has been sent.
[$else$]
[- $optDisableTableScan = 0 -]
[$if $#errors != -1 $]
| [+$errors[$row]+] |
[$endif$]
[- $optDisableTableScan = 1 -]
[$endif$]