PHP mail function issue

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

LiteSpeed Staff
#2
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.
 
#3
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

LiteSpeed Staff
#4
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.
 
#5
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

LiteSpeed Staff
#6
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.
 
#7
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

LiteSpeed Staff
#8
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.
 
#9
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

LiteSpeed Staff
#10
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.
 
#12
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...
 
#13
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 :)
 
Top