sendmail ('god@heaven.com', 'die.puny@earthling.net', 'Test', 'This is a test'); sub sendmail { my ($from, $to, $subject, $body) = @_; open(MAIL, "|/usr/lib/sendmail -oem -t -oi -f $from"); print MAIL "To: $to\n"; print MAIL "Subject: $subject\n\n"; print MAIL "$body\n"; close MAIL; } #### sendmail ('god@heaven.com', 'die.puny@earthling.net', 'Test', 'This is a test'); sub sendmail { my ($from, $to, $subject, $body) = @_; my $mailer; eval { $mailer = Mail::Mailer->new(); }; if ($@) { warn "Couldn't send mail: $@"; } else { $mailer->open({ From => $from, To => $to, Subject => $subject }); print $mailer $body; unless (close ($mailer)) { warn "Couldn't close mailer: $!"; } } }