RE: [PHP] mail() only working with php-cli
| From: | Andy B. | Date: | Tue, 08 May 2007 04:37:33 +0000 |
| Subject: | RE: [PHP] mail() only working with php-cli | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-254530@lists.php.net to get a copy of this message | ||
Thanks a lot for helping.
I found the problem while trying so su to the www-user, where I was
immediately told "/bin/bash: permission denied". Rather unusual...
The owner of the server has mistakenly changed many permissions in the
/(s)bin, /usr/(s)bin directories, so that most of the files were chmod 700
instead of 755. The suid flags were also gone.
It took me a while to rebuild the permissions, but after that mail() worked
as it should.
That being said, it really would have saved me a lot of time and anger if
mail() were a little bit more verbose in situations like that. A simple
error message like "/usr/sbin/sendmail: permission denied" would have made
it.
Regards,
----
Andy
-----Original Message-----
From: Richard Lynch [mailto:ceo@l-i-e.com]
Sent: Tuesday, May 08, 2007 01:01
To: Andy B.
Cc: php-general@lists.php.net
Subject: Re: [PHP] mail() only working with php-cli
On Sat, May 5, 2007 3:53 pm, Andy B. wrote:
> Is there any way to debug the mail() function within PHP4 or PHP5?
Check Apache error logs.
Check sendmail (or whatever) error logs.
> The following code is not working when called from a browser, but it
> does
> work from the command line:
Often points to a paths/permissions problem...
Can you 'su' to the Apache/PHP User and *then* run sendmail on command
line?
> php and php-cli use the same php.ini file. Php via Apache is launched
> as a
> module, NOT as CGI!
>
> sendmail_path is correctly set to /usr/sbin/sendmail -t -i
You put quotes around that in php.ini, right?...
Cuz it needs the quotes, last I checked:
sendmail_path = "/usr/sbin/sendmail -t -i"
> the /var/log/mail.log only shows activity when I try my code via
> command
> line, so my best guess is that sendmail is never reached when run from
> the
> browser.
>
> I went a little deeper and modified the sendmail_path to /tmp/test.sh,
> which
> contains:
>
> #!/bin/bash
> echo "I was used!!" > /tmp/test.log
>
> (chmod 777 /tmp/test.sh)
>
> Again I tried my script from the web and from the command line. Same
> result... command line is fine and generates the test.log file. In the
> browser no log file is created.
Hmmm. That blows away the quotes as an issue, at least until you got
back to using multi-word path...
Was sendmail installed when you compiled PHP, so PHP "knows" that it
should be able to use it?
Or, the short version of that question:
Does <?php phpinfo();?> show you 'mail' as an installed extension?
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?