RE: mail() only working with php-cli

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx] 
Sent: Tuesday, May 08, 2007 01:01
To: Andy B.
Cc: php-general@xxxxxxxxxxxxx
Subject: Re:  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?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux