PHP mail function issue

Discussion in 'PHP' started by hugemikeyd, Mar 1, 2007.

  1. hugemikeyd

    hugemikeyd Active Member

    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 :)
  2. mistwang

    mistwang LiteSpeed Staff

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

    hugemikeyd Active Member

    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.
  4. mistwang

    mistwang LiteSpeed Staff

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

    hugemikeyd Active Member

    Nothing is missing from the email if the same file works from the command line but doesn't when accessed through a browser:

    mail( '',
    'Just testing mail from php',
    "From: \"Testing\"<>\n".
    "Content-Type: text/plain; charset=\"utf-8\"\n".
    "Return-path: <>"

    I don't think it could be any simpler really, are there any settings in Litespeed that would prevent this from going through?
  6. mistwang

    mistwang LiteSpeed Staff

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

    hugemikeyd Active Member

    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?
  8. mistwang

    mistwang LiteSpeed Staff

    those numbers are looking fine.
    Maybe you need to set "sendmail_path" in php.ini
    details are in
    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. hugemikeyd

    hugemikeyd Active Member

    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
  10. mistwang

    mistwang LiteSpeed Staff

    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.
  11. hugemikeyd

    hugemikeyd Active Member

    The only path missing is /usr/local/bin, where am i adding this?
  12. hugemikeyd

    hugemikeyd Active Member

    I added:

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

    hugemikeyd Active Member

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

Share This Page