RE: [PHP] mail() only working with php-cli
| From: | Andy B. | Date: | Sun, 06 May 2007 09:52:59 +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-254483@lists.php.net to get a copy of this message | ||
Oliver,
Yes I also analyzed the log files from apache, but all they are telling me
is that I am accesing the file "mail.php" with my browser. Error.log stays
empty.
I wish that it were possible to reproduce an error when accessing mail()
that would somewhat look like this:
"cannot access /usr/sbin/sendmail: permission denied", then at least I know
what needs to be done. However I doubt that my php configuration is
forbidden to access this file.
----
Andy
-----Original Message-----
From: Oliver Block [mailto:lists@block-online.eu]
Sent: Saturday, May 05, 2007 23:58
To: php-general@lists.php.net
Cc: Andy B.
Subject: Re: [PHP] mail() only working with php-cli
Hello Andy,
did you take a look into the apache log files?
Regards,
Oliver
Am Samstag, 5. Mai 2007 22:53 schrieb Andy B.:
> 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@self.com';
> $subject = 'the subject';
> $message = 'hello.......';
> $headers = 'From: foo@bar.com' . "\r\n" .
> 'Reply-To: foo@bar.com' . "\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