sub mail()
Why the (), you're not shift()ing anything??
{ my $from="[EMAIL PROTECTED]"; my $to=$recipient;
Why localize a more "global" var?
why not:
my $to = shift;
or just use $recipient?
And also for the other vars?
my $sendmailpath="/usr/sbin/sendmail";
If this is hardcodes right before the only instance of it why not just hard code it in the open...
open (SENDMAIL, "| $sendmailpath -t");
What if it can't open it?
or die "open $sendmailpath failed: $!";
print SENDMAIL "Subject: From Guest Book $subject\n";
print SENDMAIL "From: $from\n";
print SENDMAIL "To: $to\n\n";
print SENDMAIL "$content\n\n";
close (SENDMAIL);
}
mail($to,$subj,$body);
sub mail {
my $path = '/usr/sbin/sendmail -f'; # I include switcheshere because what if its not sendmail, what if its say qmail?
my $from = '[EMAIL PROTECTED]';
# the two vars above you could also accept via @_ or get from a cpnfiguration of some sort.
my ($to,$sub,$bod) = @_;
open MAIL, "| $path" or die "open of $path failed: $!"; print MAIL <<MAILX; Subject: Fron Guest Book $sub From: $from To: $to
$bod MAILX close MAIL; }
The problem is then this code is not very portable and still relies on external programs to:
- exist - be executable - handle what your piping to it to do what you want
So it'd be better to use Mail::Sender and do real SMTP :)
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>