Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

My call to open /usr/lib/sendmail fails. The path for sendmail has been checked, debug messages inserted, different email apps used. The privileges are all rwx. Can anyone give me a suggestion why my call won't open the mail app?
sub send_mail { print "<pre>starting sub send_mail...\n"; # Localize variables used in this subroutine. + # local($print_config,$key,$sort_order,$sorted_field,$env_report); # Open The Mail Program # open(MAIL,"|$mailprog -t -f || die"" couldn't open mailprog $!") +; print "opening mail: $mailprog\n"; open (MAIL,"|/usr/ucb/mail -t") || warn "couldnt open mailprog: $! +\n"; print "opened mail\n"; #print MAIL "To: $Config{'recipient'}\n"; print MAIL "To: cgi_test\n"; print MAIL "From: $Config{'email'} ($Config{'realname'})\n"; print MAIL "Subject: TEST\n\n"; print MAIL "this is the body of the email\n"; # Check for Message Subject if ($Config{'subject'}) { print MAIL "Subject: $Config{'subject'}\ +n\n" } else { print MAIL "Subject: ONG TAC OUTAGE Form + Submission\n\n" } print MAIL "Below is the result of your feedback form. It was sub +mitted by\n"; print MAIL "$Config{'realname'} ($Config{'email'}) on $date\n"; print MAIL "-" x 75 . "\n\n";

Replies are listed 'Best First'.
Re: open MAIL fails
by grinder (Bishop) on Jul 26, 2001 at 21:13 UTC
    The line

    open (MAIL,"|/usr/ucb/mail -t") || warn "couldnt open mailprog: $!\n";

    What does that print out? What does $! contain? Another thing, /usr/ucb/mail is not the same thing as /usr/lib/sendmail, but I guess that's obvious.

    A really nice module, one that will cause you considerably less grief, is Mail::Sendmail, which, curiously enough, does not require the use of sendmail, but rather is a replacement for it. You can also coax it to do MIME messages if you have to.

    --
    g r i n d e r
Re: open MAIL fails
by MZSanford (Curate) on Jul 26, 2001 at 21:11 UTC
    It appears here you are opening /usr/ucb/mail and not sendmail. Otherwise, this appears it would work. In the prior line, you would need :
    # old open(MAIL,"|$mailprog -t -f || die"" couldn't open mailprog $!") # new open(MAIL,"| $mailprog -t -f") || die "couldn't open mailprog $!";
    hope that helps
    update: this is , assuming, $mailprog is /usr/lib/sendmail
    Thus spake the Master Programmer:
    "When you have learned to snatch the error code from the trap frame, it will be time for you to leave."
    -- The Tao of Programming