ID:               30647
 Updated by:       [EMAIL PROTECTED]
 Reported By:      jurgen at person dot be
-Status:           Open
+Status:           Bogus
 Bug Type:         Mail related
 Operating System: FreeBSD
 PHP Version:      5.0.2
 New Comment:

It's obviously not any bug in mail() but just some configuration issue
with qmail. (mail() was meant to be used with sendmail, with anything
else: your mileage will vary)

As you said: "I knew once the solution, but I forgot
to take notes."

Try google.



Previous Comments:
------------------------------------------------------------------------

[2004-11-01 12:28:18] jurgen at person dot be

Description:
------------
I have a problem with the PHP mail() function on a running Qmail
server
on FreeBSD 5.2.1.  Pretty like this problem, I found in the mail
archive : 
http://lists.freebsd.org/pipermail/freebsd-questions/2003-August/017231.html

Would You PLEASE set the solution somewhere on the php.net
documentation, because 
this problem returns very often.  I knew once the solution, but I
forgot to take
notes.

OS                       : FreeBSD 5.2.1
Mailserver: Qmail
PHP       : 5.0.2 (4.3.9 same error)

Step 1: Testing of the qmail server in shell:

I create a test.eml file with:
<snip>
Message-ID: <[EMAIL PROTECTED]>
Date: Wed, 27 Oct 2004 11:00:37 +0200
From: me <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: Local test
 
Helleuu.
</snip>

I test the mailserver from shell with:
cat test.eml | /var/qmail/bin/qmail-inject      (mail arrives)
cat test.eml | /usr/sbin/sendmail -t -i                 (mail arrives)
mail -s "test" [EMAIL PROTECTED] < test.eml       (mail arrives)

Step 2: I deinstalled the whole bunch of PHP 4.3.9 with:
pkg_delete -x "php4*"
pkg_delete -x "pecl-*"
rm -d -r /usr/local/lib/php /usr/local/include/php

Step 3: Install minimum PHP system.

cd /usr/ports/lang/php5
make WITH_APACHE=yes PHP_SAPI=full
make WITH_APACHE=yes  PHP_SAPI=full install

Step 4: Configure right php.ini and verify it works

cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini

Change 
;sendmail_path
into
sendmail_path = /var/qmail/bin/qmail-inject

(note: same behaviour when i use, or I use ; before sendmail)
sendmail_path = /usr/sbin/sendmail -t -i 

qmail-inject can be accessed and executed from others.

Write a test.php with
<?
        phpinfo();
?>

# php -v
PHP 5.0.2 (cli) (built: Oct 31 2004 11:12:24) (DEBUG)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v2.0.2, Copyright (c) 1998-2004 Zend Technologies

(Ok next time i try WITH_DEBUG=no)

#php -m
[PHP Modules]
libxml
SPL
Standard

#php -f test.php | grep sendmail_path
sendmail_path => /var/qmail/bin/qmail-inject =>
/var/qmail/bin/qmail-inject

(Ok, seems OK)

Step 5: testing mail from PHP

A simple test2.php:
<? mail("[EMAIL PROTECTED]", "Subjet", "Test mail"); ?>

#php -f test2.php

->Same results, the script sits waiting/running whatever.
No core dumped, it just runs and waits...

Step 6: Let the script run and try another session

ps -aux and i have this:

(using mailwrapper)
root        8803  0.0  0.9  6152 3440  p0  I+    4:44PM   0:00.17 php
-f test2.php
root        8804  0.0  0.1   908  332  p0  I+    4:44PM   0:00.02 sh -c
/usr/sbin/sendmail -t -i
root        8805  0.0  0.2  1256  584  p0  I+    4:44PM   0:00.08
bin/qmail-inject -H --
qmailq      8806  0.0  0.1  1224  512  p0  I+    4:44PM   0:00.04
bin/qmail-queue

So the script initiates the wrapper; qmail-inject and qmail-queue)

(using qmailinject directly from php.ini)
root        8962  0.0  0.9  6152 3440  p1  I+    5:00PM   0:00.16 php
-f testmail.php
root        8963  0.0  0.1   908  332  p1  I+    5:00PM   0:00.02 sh -c
/var/qmail/bin/qmail-inject
root        8964  0.0  0.2  1256  584  p1  I+    5:00PM   0:00.03
/var/qmail/bin/qmail-inject
qmailq      8965  0.0  0.1  1224  512  p1  I+    5:00PM   0:00.03
bin/qmail-queue

In this case the script initiates qmail-inject directly and
qmail-queue)

But why does it stucks, waits and the phpscript keeps running ? 

Step 7: Use qmail-inject directly with printout to screen option

Change php.ini with 
sendmail_path = /var/qmail/bin/qmail-inject -H -n


#php -f test2.php
Return-Path: <my-mail>
Date: 31 Oct 2004 16:59:51 -0000
Message-ID: <[EMAIL PROTECTED]>
From: mymail
To: [EMAIL PROTECTED]
Subject: Subjet


 
Test mail

(and the script does NOT return to the promp)

Step 8: Verify what's going on with qmail-stat in a seconday shell

#/var/qmail/bin/qmail-qstat
messages in queue: 4

--> when the script is started it is raised  +1
--> when teh script is stopped it is lowered -1

So the mail get stucks into the queue and refuse to be processed
further.
What to do ?!

Expected result:
----------------
The mail() function should handle more deeple the mail process.  We
looked to phpmailer.sourceforge.net  Maybe this would be a better
solution to invake it owns SMTP protocol.
Or maybe it should be used as extension.

Anyway mail() should never hang/deadloop a script, running from the
prompt.  It should catch the reason why it does not succeed.

So I think it's related to the communication between mail() and the
mailserver, because the mail() sits to wait for 'something' before it
continues it scripts.  Maybe the pipe is broken, the handle is closed. 
But I would known the reason, because this event returns, and returns on
questions and should be made public on the documentation.

Actual result:
--------------
How do You do backtracing from shellprompt ?!


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=30647&edit=1

Reply via email to