hello all,
i need help modifying a small perl script that sends an email after a form is submitted.
i need to be able to receive the email in html format, but my knwoledge of perl is very poor.
please any help at this moment would be fantastic.
thank you.
here is my script:
i need help modifying a small perl script that sends an email after a form is submitted.
i need to be able to receive the email in html format, but my knwoledge of perl is very poor.
please any help at this moment would be fantastic.
thank you.
here is my script:
Code:
l#!/usr/bin/perl -w
use Net::SMTP;
use CGI;
my $cgi = new CGI;
sub send_mail
{
my $to = $_[0];
my $subject = $_[1];
my $body = $_[2];
my $from = $_[3];
my $smtp;
if (not $smtp = Net::SMTP->new('mail.server.com', Port => 25, Debug => 1))
{
die "Could not connect to server\n";
}
$smtp->mail($from . "\n");
my @recepients = split(/,/, $to);
foreach my $recp (@recepients)
{
$smtp->to($recp . "\n");
}
$smtp->data();
$smtp->datasend("From: " . $from . "\n");
$smtp->datasend("To: " . $to . "\n");
$smtp->datasend("Subject: " . $subject . "\n");
$smtp->datasend("\n");
$smtp->datasend($body . "\n");
$smtp->dataend();
$smtp->quit;
}
# Send away!
&send_mail($cgi->param('to'), $cgi->param('subject'), $cgi->param('body'), $cgi->param('from'));
print $cgi->header;
print '<html><body>Your e-mail has been sent</body></html>';
Comment