Re: mail() only working with php-cli

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

 



On 5/5/07, Andy B. <globi@xxxxxx> wrote:
Is there any way to debug the mail() function within PHP4 or PHP5?

The following code is not working when called from a browser, but it does
work from the command line:

<?php
$to      = 'my@xxxxxxxx';
$subject = 'the subject';
$message = 'hello.......';
$headers = 'From: foo@xxxxxxx' . "\r\n" .
   'Reply-To: foo@xxxxxxx' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();

if(mail($to, $subject, $message, $headers))
       echo "IT WORKED";
else
       echo "DAMN!!!";
?>


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

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.

I have already made numerous LAMP installations, but I never had this kind
of mail() issue. This installation is quite simple: standard Apache 2.0 with
php5, php5-mysql, php5-gd, ... This makes it even more frustrating :-(

What am I missing?

Thanks a lot!!

----
Andy


Are you sure that the PHP CLI and PHP-module are exactly the same build?
And you could try to set error reporting level to E_ALL, maybe there's
a warning generated that's hidden now because of a lower reporting
level.

Tijnema

--
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