Hi peterr, I seem to have made you fall in love with sysopen. Fact - mostly you don't use it, you use plain open.

OK so you have this code:

open(SENDMAIL, '|/usr/sbin/sendmail -oi -t') or (unlink ($outfile), diehtml("Can't fork for sendmail: $!\n"));

First the syntax would usually be:

open(SENDMAIL, '|/usr/sbin/sendmail -oi -t') or do{ unlink($outfile); diehtml("Can't fork for sendmail: $!\n")};

Although what you have is valid. There are two parts to this line. The open() and the do{} joined by an or. How this works is this. If open works it returns 1 (true), if it fails it returns 0 (fail).

TRUE or do{does not get done} FALSE or do{does get done}

Where the TRUE/FALSE return value from open determines if the or do{} gets executed.

So presuming you are right (I don't see how this will hang) there is an issue with sendmail. What the open is doing is opening a pipe | to the sendmail binary onto the filehandle SENDMAIL. You will then be doing this:

print SENDMAIL $msg close SENDMAIL;

I presume you are sure it hangs in the open ie you have:

warn "Before SENDMAIL open\n"; open(SENDMAIL.....) warn "After open\n";

And have checked the error logs to confirm that this is exactly the problem.....If it is really hanging on that open then I suggest you have a real probelem with your host. Remember you had hanging with another shell call to lockfile (that should not of hung either)

You can test sendmail on the command line:

[root@devel3 root]# which sendmail /usr/sbin/sendmail [root@devel3 root]# /usr/sbin/sendmail -t To: root@localhost Hello Me! . [root@devel3 root]# tail /var/mail/root Received: (from root@localhost) by devel3.XXXXXXXXXX.org (8.11.6/8.11.6) id h933ZZq18591; Fri, 3 Oct 2003 03:35:35 GMT Date: Fri, 3 Oct 2003 03:35:35 GMT From: root <root@devel3.XXXXXXXXX.org> Message-Id: <200310030335.h933ZZq18591@devel3.XXXXXXXXX.org> To: root@devel3.XXXXXXXXX.org Hello Me! [root@devel3 root]#

You can use sendmail directly as shown. The . on the line by itself lets sendmail know you are done.

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: Sendmail problems by tachyon
in thread Sendmail problems by peterr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.