P
Phantom_guitarist
I am currently having problems creating a script to send an email from perl.
I have got the script down to the bare minimum;
#!/usr/bin/perl
print "Content-type:text/html\n\n";
&mail('(e-mail address removed)','(e-mail address removed)','Test
Message','Test Message');
print "<br>Mail Sent";
sub mail
{
print "Preparing to send<br>";
# first param is recipient
# second is from
# third is subject
# fourth is message
$mailprog = '/usr/sbin/sendmail';
$recipient = $_[0];
$from = $_[1];
$subject = $_[2];
$message = $_[3];
print "To: $recipient\n<br>";
print "From: $from\n<br>";
print "Subject: $subject\n\n<br>";
print $message;
print "<br>";
open(MAIL,'|$mailprog')|| &error("Cant locate mail program");
print MAIL "To: $recipient\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
print MAIL $message;
close (MAIL);
}
sub error
{
print "Content-type:text/html\n\n";
print $_[0];
exit;
but for some reason this doesn't work. It doesn't display any messages and
the script runs fine. I have contact the domain hosting I am with
(http://www.kthosting.com) and they couldn't give me any reason why the
script doesn't work. They have a FromMail.cgi script on their site and that
seems to work ok on sending to my address. If any one knows of any issues
that I am maybe overlooking your help would be very much appreciated.
Stefan
I have got the script down to the bare minimum;
#!/usr/bin/perl
print "Content-type:text/html\n\n";
&mail('(e-mail address removed)','(e-mail address removed)','Test
Message','Test Message');
print "<br>Mail Sent";
sub mail
{
print "Preparing to send<br>";
# first param is recipient
# second is from
# third is subject
# fourth is message
$mailprog = '/usr/sbin/sendmail';
$recipient = $_[0];
$from = $_[1];
$subject = $_[2];
$message = $_[3];
print "To: $recipient\n<br>";
print "From: $from\n<br>";
print "Subject: $subject\n\n<br>";
print $message;
print "<br>";
open(MAIL,'|$mailprog')|| &error("Cant locate mail program");
print MAIL "To: $recipient\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
print MAIL $message;
close (MAIL);
}
sub error
{
print "Content-type:text/html\n\n";
print $_[0];
exit;
but for some reason this doesn't work. It doesn't display any messages and
the script runs fine. I have contact the domain hosting I am with
(http://www.kthosting.com) and they couldn't give me any reason why the
script doesn't work. They have a FromMail.cgi script on their site and that
seems to work ok on sending to my address. If any one knows of any issues
that I am maybe overlooking your help would be very much appreciated.
Stefan