#!/usr/bin/perl # Choice method of sending, sendmail or SMTP $mail_prog='smtp:mail.MYWEBSITE.com'; #$mail_prog="/usr/sbin/sendmail"; $addr_to="neil\@MYEMAIL.com"; $addr_from="hi\@MYEMAIL.com"; $|=1; print "Content-type:text/html;charset=ISO-8859-1\n\n
";
print "Mail Test program...\n";
# Get a blank line between each line (as expected)
$rest_of_msg="Subject:This is a subject\n\n";
$rest_of_msg.="A reply has been posted to your message on the website blah blah blah.\n\n";
$rest_of_msg.="The URL for the response is\n\n";
$rest_of_msg.="http://www.awebsite.com/cgi/software/program.pl?f=1&m=254388&df=1\n\n";
&send_an_email($addr_to,$addr_from,$rest_of_msg);
# Doesn't do any line feeds!
$rest_of_msg="Subject:This is a subject\n\n";
$rest_of_msg.="A reply has been posted to your message on the website blah blah blah.\n";
$rest_of_msg.="The URL for the response is\n";
$rest_of_msg.="http://www.awebsite.com/cgi/software/program.pl?f=1&m=254388&df=1\n";
&send_an_email($addr_to,$addr_from,$rest_of_msg);
print "Sent!";
exit;
sub send_an_email{
my($to,$from,$rest)=@_;
if(substr($mail_prog,0,5) eq 'smtp:'){
require Net::SMTP;
my $smtp=substr($mail_prog,5);
$smtp = Net::SMTP->new($smtp);
$smtp->mail($from);
$smtp->to($to);
$smtp->data();
$smtp->datasend("To:$to\nFrom:$from\n$rest");
$smtp->dataend();
$smtp->quit();
}else{
open MAIL,"|$mail_prog -t";
print MAIL "To:$to\nFrom:$from\n$rest";
close MAIL;
}
}
####
A reply has been posted to your message on the website blah blah blah.
The URL for the response is
http://www.awebsite.com/cgi/software/program.pl?f=1&m=254388&df=1