View Full Version : PHP mail function issue
hugemikeyd
03-01-2007, 10:20 AM
I cannot seem to send an email message using Litespeed, but I can use the same file from the command line with success.
I am not really sure what's going on here, i feel like it may be permissions, but i tried sending as the user that Litespeed is run under and it works.
I'm hoping to get some ideas to try in here :)
mistwang
03-01-2007, 10:37 AM
What kind of method are you using to send email, sendmail? mail? or SMTP?
It is a PHP problem, you can use "strace" to trace the PHP process to find out what exactly causes it.
hugemikeyd
03-01-2007, 11:15 AM
Well this is the thing, i created a file using the mail function that just sends out an email to me, nothing fancy at all. If i run it from the command prompt as the user Litespeed is run as, it works just fine. I can see the email enter my qmail queue and then it goes out.
When i use the same file as a web request, the email enters my mail queue but never gets sent out.
The only difference is that i am triggering it using LSAPI rather than on the command prompt.
My PHP is compiled by me and both the CLI and LSAPI have the same exact configure setting with the exception of "--with-litespeed".
That's why i think it may be something with my configuration.
mistwang
03-01-2007, 12:10 PM
You can use the LSAPI version as the CLI one.
If the email got into the mail queue, it may not be a PHP email problem, maybe missing something in the email message itself.
hugemikeyd
03-01-2007, 12:31 PM
Nothing is missing from the email if the same file works from the command line but doesn't when accessed through a browser:
mail( 'someemail@gmail.com',
'Just testing mail from php',
'blah',
"From: \"Testing\"<test@testdomain.com>\n".
"Content-Type: text/plain; charset=\"utf-8\"\n".
"Return-path: <test@testdomain.com>"
);
I don't think it could be any simpler really, are there any settings in Litespeed that would prevent this from going through?
mistwang
03-01-2007, 01:00 PM
I think there might be something in php.ini prevent the mail function work properly. You can try CLI or LSAPI PHP from comand line using option "-c <path_to_php.ini>", see if you get the same result as run under LSWS.
For LSWS configuration, please double check process soft/hard limit and memory limit, make sure they are large enough.
hugemikeyd
03-01-2007, 01:30 PM
using the -c option from the command line still results in the email being sent.
My current options for the memory and process limits are:
Memory Soft Limit (bytes) number 100M
Memory Hard Limit (bytes) number 200M
Process Soft Limit number 200
Process Hard Limit number 200
Should they be higher?
mistwang
03-01-2007, 02:15 PM
those numbers are looking fine.
Maybe you need to set "sendmail_path" in php.ini
details are in http://us3.php.net/mail
LSWS will not pass your shell PATH environment to PHP started by it, instead, it set PATH to "/usr/bin:/bin", so a wrong "sendmail" might be used. you can set PATH in environment explicitly as well.
hugemikeyd
03-01-2007, 05:44 PM
My php.ini settings are correct:
Path to sendmail: /var/qmail/bin/sendmail
So it's a full path. I don't have a sendmail under /usr or /usr/lib
mistwang
03-01-2007, 06:02 PM
Then try set PATH environment variable to the same value as your shell, if there is other environment variables required by qmail, add them to lsphp's environment.
hugemikeyd
03-01-2007, 07:35 PM
The only path missing is /usr/local/bin, where am i adding this?
hugemikeyd
03-01-2007, 07:51 PM
I added:
PATH=/bin:/sbin:/usr/local/bin
to my lsapi configuration and it didn't seem to help...
Are there log files i can look at regarding this?
It just makes no sense...
hugemikeyd
03-02-2007, 01:39 PM
So apparently, and i am not sure why at all, but sendmail requires 2 parameters to work correctly:
-t -i
so once i updated my sendmail path to include this, it works!
Thanks for the suggestions :)