PDA

View Full Version : sending email with perl



ktpmm5
09-02-2008, 05:18 PM
I'm using a cron job to launch a perl script that grabs data out of my db and sends an email depending on the results. Had no luck with the simple perl function below - seems to work locally, but not at BH - anyone have any suggestions?

sendEmail("to\@domain.com", "from\@domain.com", "Reminder", "This is a test of the email function.");


sub sendEmail
{
my ($to, $from, $subject, $message) = @_;
my $sendmail = '/usr/lib/sendmail';
open(MAIL, "|$sendmail -oi -t");
print MAIL "From: $from\n";
print MAIL "To: $to\n";
print MAIL "Subject: $subject\n\n";
print MAIL "$message\n";
close(MAIL);
}

BenInBlack
09-03-2008, 03:00 AM
another options would be to do it using PHP/MySql.
I have used this mailer class for years
http://www.xpertmailer.com/

I use it in my simple time tracking app I am running in PHP on blue host and it emails out nice html formated emails.

Just a thought ;)

siguie
09-03-2008, 03:16 AM
Try ...

open (MAIL, "|/usr/sbin/sendmail -t") || die "cant open Mail program";