#30647 [NEW]: mail() keeps script running however initiates mailwrapper
| From: | jurgen at person dot be | Date: | Mon, 01 Nov 2004 11:28:36 +0000 |
| Subject: | #30647 [NEW]: mail() keeps script running however initiates mailwrapper | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-68582@lists.php.net to get a copy of this message | ||
From: jurgen at person dot be
Operating system: FreeBSD
PHP version: 5.0.2
PHP Bug Type: Mail related
Bug description: mail() keeps script running however initiates mailwrapper
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: <802973227.20041027110037@person.be>
Date: Wed, 27 Oct 2004 11:00:37 +0200
From: me <me@mydomain.loc>
To: me2@mydomain.loc
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" me@mydomain.loc < 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("me@mydomain.loc", "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: <20041031165951.9252.qmail@mydomain>
From: mymail
To: jurgen@person.be
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 bug report at http://bugs.php.net/?id=30647&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30647&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30647&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30647&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=30647&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=30647&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=30647&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=30647&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=30647&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=30647&r=support
Expected behavior: http://bugs.php.net/fix.php?id=30647&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=30647&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=30647&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=30647&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30647&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=30647&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=30647&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=30647&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=30647&r=float
MySQL Configuration Error: http://bugs.php.net/fix.php?id=30647&r=mysqlcfg