php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #448 mail() fails in CGI
Submitted: 1998-06-10 15:05 UTC Modified: 1998-06-10 19:19 UTC
From: mcglynn at netjet dot com Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0 Final Release OS: all
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mcglynn at netjet dot com
New email:
PHP Version: OS:

 

 [1998-06-10 15:05 UTC] mcglynn at netjet dot com
The mail() function fails in 3.0. The bug is that recipients are not specified.

I've tested this under Linux (with qmail) and Solaris (with sendmail).

The test script is simply <? mail ($somevalidaddress, "ping", "you'll never see this"); ?>

My most recent proof of the bug can be seen in the following shell transcript (from SunOS 5.5.1):
> cat zmailtest.php3
#!/usr/local/bin/php3 -q
<?
    echo "Working...\n";
    mail ("matt@debris.com", "ping from 3.0", "nada") or die ("mail error");
    echo "done";
    ?>
> ./zmailtest.php3
Working...
mcglynn... Recipient names must be specified
Saving message in /home/mcglynn/dead.letter
/home/mcglynn/dead.letter... Can't create output: Operation not permitted
done>

(I don't know why it can't create the dead.letter output but the error message indicates that no recipients were defined.)


The background on this can be found in my post to the PHP3 list, included here, and my later post to PHP3-DEV (also below).

msg originally sent 6/9/98 to php3@lists.php.net:
------------------------------------------------
I built standalone CGIs of 3.0 and RC3 on a Linux system:
Linux ns 2.0.32 #4 Wed Dec 31 11:39:15 PST 1997 i486 unknown

Using two simple scripts that are identical except for the
version of the PHP3 CGI they invoke, I've discovered that
the full 3.0 release seems to have an error in its mail()
function.

The two scripts generate a mail to a remote host. I ran the
two scripts one after another and only one mail appeared.
Here are the relevant log lines:

Jun  9 19:05:26 me qmail: 897444326.332762 new msg 56066
Jun  9 19:05:26 me qmail: 897444326.333788 info msg 56066: bytes 264 from <mcglynn@xx.yy.zz> qp 12205 uid 1000
Jun  9 19:05:26 me qmail: 897444326.402506 end msg 56066

Jun  9 19:05:32 me qmail: 897444332.624872 new msg 56066
Jun  9 19:05:32 me qmail: 897444332.625905 info msg 56066: bytes 266 from <mcglynn@xx.yy.zz> qp 12208 uid 1000
Jun  9 19:05:32 me qmail: 897444332.827715 starting delivery 1894: msg 56066 to remote matt@debris.com
Jun  9 19:05:33 me qmail: 897444333.827335 delivery 1894: success: 207.21.175.30_accepted_message./Remote_host_said:_250_Message_received_OK/
Jun  9 19:05:33 me qmail: 897444333.887786 end msg 56066

In the second case, you can see qmail make the remote delivery
(to matt@debris.com). In the first case, there is no delivery
attempt at all.

I would think this is a mail configuration error, but since
RC3 is able to generate the mail, now I think that PHP is
somehow truncating the recipients from the mail invocation (?).

Here is the RC3 do-conf:
./configure --with-mysql --with-config-file-path=/home/httpd/apache/conf --enable-debug=no

Here is the 3.0 do-conf:
./configure --with-gd=no --with-mysql --with-config-file-path=/home/httpd/apache/conf --enable-debug=no 
--enable-track-vars=yes

Here is the relevant line from /home/httpd/apache/conf/php3.ini:
sendmail_path=/var/qmail/bin/sendmail

(/var/qmail/bin/sendmail is qmail's sendmail wrapper -- again,
I know it works because RC3 doesn't have a problem)


msg originally sent 6/10/98 to php-dev@php.iquest.net:
------------------------------------------------------
I'm following up on an anomaly that I reported to the PHP3
list last night. In a nutshell, the problem is this: I have
two PHP3 standalone binaries (RC3 and 3.0 final). One can
send mail; the other can't.

In my post to the list yesterday I showed syslog lines that
indicate that qmail makes no delivery attempt on the mail
generated by the 3.0 final binary. Someone on the qmail list
suggested that the mail was showing up with no recipients.
Seems unlikely somehow, but I have anecdotal evidence that
this may be the case: when I generate a mail message with
no recipients on the command line, the syslog is the same
as when the PHP3.0 binary generates mail. That is, there is
no delivery attempt.

I ran a diff against mail.c in RC3 and 3.0 and found that 
there were a lot of changes made. One stood out: 
    fprintf(sendmail, "\n%s\n.\n", message);  
in RC3 became
    fprintf(sendmail, "\n%s\n", message);  
in 3.0.

I noted in my syslog that the 3.0 mail was 2 bytes shorter,
and I wondered if the trailing dot-newline was significant.
(Seemed obvious that those were the two bytes that were
missing.) So I made the change to 3.0 and recompiled, but
alas, mail() still fails.

So my query to you is this: how can I output or trap the
data stream that PHP is sending to my mailer?

Oh, BTW, php3.ini has defined sendmail as /var/qmail/bin/sendmail,
which works (remember that RC3 can generate mail just fine).

I'd like to dump the output of the mail() function to a terminal
or text file somewhere so I can see if there's an obvious
error -- like a missing newline in a critical place, or something.
I don't know qmail well enough to know how to change its logging
behavior or I'd pursue this there as well.

I suppose I could just log this as a bug but I'd just as soon
nail down a fix and implement it today if I can.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-06-10 19:19 UTC] rasmus
not a bug - fixed by putting correct entry in the .ini file
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 05:01:29 2024 UTC