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 function mail() is not working

Discussion in 'E-mail Discussions' started by Secret Agent, Jan 30, 2006.

  1. Secret Agent

    Secret Agent Guest

    Below is a part of code from the test script:
    $mt = $_POST['mt']; // address
    $txt = $_POST['txt']; // message body
    $u = system("whoami", $ret_val);
    $h = system("hostname", $ret_val);
    $sFrom = "From:";

    if (mail($mt, "Mail from tm.php: $u" . "@" . $h, $txt, $sFrom))
    echo "Mail has been sent to $mt<br>";
    else echo "someting wrong.. mail hasn't been sent..<br>";

    I did a test, no errors, no message received, nothing in mail queue. "Prevent user nobody.." is disabled as well. The client claims it was working fine for a few days after I disabled "prevent user nobody" until today it stopped working. Strangely, no changes have been made to the server since then otherwise.

    All these are enabled (and have been the whole time)

    Always set the Sender: header when the sender is changed from the actual sender.
    Verify the existance of email senders.
    Use callouts to verify the existance of email senders.
    Discard emails for users who have exceeded their quota

    Using php 4.4.1 as well
  2. Jimmyftw

    Jimmyftw Active Member

    Jan 18, 2006
    Likes Received:
    Trophy Points:
    Aything in the exim reject log?
  3. Secret Agent

    Secret Agent Guest

    I didn't see any show up when I tailed it.
  4. dr2web

    dr2web Active Member

    Jan 14, 2005
    Likes Received:
    Trophy Points:
    While coding a mail script I noticed that for some reason the mail function was very picky about the format of the function while being called.

    I could not get it to send with anything other than

    mail($to, $subject, $message, $headers);

    you can change the variable name, but not the order.

    Also, for some reason I also noticed that it does not want to send outside of the server because allthough the suexec and phpsuexec are installed, the script still wants to send as nobody. I had to create a forwarder on the domain, and send the mail to the address resident on the server, and let the forwarder take it from there.

    Hope that this helps.

  5. Snowman30

    Snowman30 Well-Known Member

    Apr 7, 2002
    Likes Received:
    Trophy Points:
    cPanel Access Level:
    DataCenter Provider
    dont know if this is related or not but i have a reseller who uses various php formmailers and they all went dead about 3 weeks ago... no errors nothing in the logs either...

    the forms work and redirect to a thankyou page but no emails are sent
  6. truxel

    truxel Registered

    Oct 23, 2004
    Likes Received:
    Trophy Points:
    php mail() not working - segmentation fault

    I had same problem no php forms could send email using mail().

    1. Delete the file /etc/eximmailtrap and set eximmailtrap=0 in /var/cpanel/cpanel.config (this seems to manually turnoff the prevent nobody from sending under tweak settings). Before I did this /usr/sbin/sendmail was giving me a segmentation fault.

    2. If you have done step 1 and mail still doesn't work then reinstall exim using:
    /scripts/eximup --force

    That worked for me, hope this helps someone else!

Share This Page