The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

php mail() will not work for user nobody, runs fine as root

Discussion in 'E-mail Discussions' started by mraberration, Jan 3, 2005.

  1. mraberration

    mraberration Member
    PartnerNOC

    Joined:
    May 22, 2004
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Orlando, FL
    Have a server that just started to not accept form mail sent by php scripts. There is no suexec or phpsuexe and exim is configured to allow localhost to sendmail. ...php mail() will not work for user nobody, runs fine as root. Any help would be greatly appreciated!
     
    #1 mraberration, Jan 3, 2005
    Last edited: Jan 3, 2005
  2. webhostfreak1

    webhostfreak1 Member
    PartnerNOC

    Joined:
    Oct 13, 2004
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    We've run into a similar problem.

    1.) Tried to rebuild exim numerous times.

    2.) Root can execute a php script and send mail, but when it goes through the web server, there's not even an indication that the mail was trying to go through exim in the /var/log/exim_mainlog nothing happens there.

    3.) The setting "Prevent user nobody from sending emails" is OFF - UNCHECKED.

    4.) We've rebuilt Apache and PHP serveral times with different options.

    5.) We've tried just about everything possible. Over 6 hours of searching and working on this and still the exact same results.

    The main problem is that when sending mails through Apache using PHP the mail goes straight to /dev/null or some other black hole and doesn't even hit the /var/log/exim_mainlog or even /var/log/exim_paniclog.

    We've tried numerous PHP scripts, but like I said, they work fine on the command line, so I don't believe it's the code.

    We've tried the latest EDGE release, the Stable release AND the current releases. We've tried upgrading all the server software, the backend scripts etc. It's no luck.

    I would also like to note that the regular EXIM works just fine. Clients and send / receive email just fine. Just not with Apache / PHP.

    safe_mode is OFF in PHP. User nobody is allowed to send email via the WHM settings. SMTP tweak is OFF. All of the email settings are wide open, but this still won't work!


    Any ideas? This one is beyond frustrating.
     
  3. andyf

    andyf Well-Known Member

    Joined:
    Jan 7, 2002
    Messages:
    246
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    UK
    Check your setting for 'sendmail_path' in php.ini, I believe it should contain:
    Code:
    sendmail_path = /usr/sbin/sendmail -t -i
     
  4. webhostfreak1

    webhostfreak1 Member
    PartnerNOC

    Joined:
    Oct 13, 2004
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    The sendmail path is correct. I've checked that when the problems started happening. I've also tested the /usr/sbin/sendmail binary from the command line and it works.
     
  5. andyf

    andyf Well-Known Member

    Joined:
    Jan 7, 2002
    Messages:
    246
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    UK
    Tailed the error_log to see if any error is being generated when the mail function is being used?
     
  6. mraberration

    mraberration Member
    PartnerNOC

    Joined:
    May 22, 2004
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Orlando, FL
    There is no error when mail() is called... I
     
  7. webhostfreak1

    webhostfreak1 Member
    PartnerNOC

    Joined:
    Oct 13, 2004
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    As stated in the long winded post, NOTHING is getting entered into the exim_mainlog when mail is being sent through PHP from the web server. If I execute the script as root:

    php script.php

    The mail gets sent and the logs correspond.

    Nothing is presented in Apache's error logs or the system logs. It's like nothing happens at all.
     
  8. webhostfreak1

    webhostfreak1 Member
    PartnerNOC

    Joined:
    Oct 13, 2004
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    At this point, we've completely removed EXIM and reinstalled it. We removed ALL references to PHP in /usr/local/include/php and /usr/local/lib/php

    We've removed /usr/local/apache and rebuilt it using easyapache. Still no luck. Nothing gets sent and nothing gets logged. Something really really strange is happening.
     
  9. webhostfreak1

    webhostfreak1 Member
    PartnerNOC

    Joined:
    Oct 13, 2004
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    Here's what fixed our problem. /bin/sh was not executable.

    Look:

    root@freak5 [~]# ls -alh /bin/
    -rwx------ 1 root root 572K Aug 18 12:23 bash*
    lrwxrwxrwx 1 root root 4 Dec 10 04:50 sh -> bash*

    Notice the permissions on bash ? It needs to be executable by nobody as well. This fixed the problem.
     
Loading...

Share This Page