Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Member
    Join Date
    May 2011
    Posts
    11

    Default mail() funtion in php not sending email, not producing error

    I'm trying to get my app to send an email. I have the following code, as a test:

    function sendTestEmail() {
    $to = 'myemailaddress@gmail.com';
    $subject = "Share your page with the world!";
    $body = "This is a test message\n\n";
    $headers = 'From: no-reply@pubfish.com' . "\r\n" .
    'Reply-To: no-reply@pubfish.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
    if (mail($to, $subject, $body, $headers)) echo 'Sent';
    else echo 'Error';
    exit();
    }

    When I run it, it completes fine, and echoes 'Sent'. However, the email never arrives. I've searched online, and most people who've come across this seem to have fixed it by changing "Prevent “nobody” from sending mail" to 'off'. I tried that, and it was already off.

    I didn't set up the server, someone else did - I can't contact him directly, so I'd like to be able to figure this out myself (also so I would know how it works). I don't know if anything was set up for emailing. I haven't mentioned email settings anywhere in my code, as I don't know whether I need to. I'm kind of new to this sort of thing.

    I'd be really grateful for any pointers anyone can give me. What kinds of settings etc should I be checking?

    Thanks!

  2. #2
    cPanel Staff cPanelTristan's Avatar
    Join Date
    Oct 2010
    Location
    somewhere over the rainbow
    Posts
    6,305
    cPanel/Enkompass Access Level

    Root Administrator

    Default Re: mail() funtion in php not sending email, not producing error

    Have you checked the exim logs for any information?

    Code:
    exigrep myemailaddress@gmail.com /var/log/exim_mainlog
    Also, how are you testing the script? Are you doing it via command line to run the script or using a browser?
    cPResources: Support Options | More Support Options | Forums Search | cPanel.net Site Search | Mailing Lists(Alt) | Docs
    -- Tristan, Forums Technical Analyst, cPanel Tech Support

    Submit a ticket | Check an existing ticket

  3. #3
    Member
    Join Date
    May 2011
    Posts
    11

    Default Re: mail() funtion in php not sending email, not producing error

    Hi, thanks for your reply.

    I've been testing in the browser (I haven't set up command line access yet). I can't find the exim logs - var isn't listed when I click on File Manager, and I looked round but couldn't see it anywhere else. Can you point me in the right direction?

    Thanks again.

  4. #4
    cPanel Staff cPanelTristan's Avatar
    Join Date
    Oct 2010
    Location
    somewhere over the rainbow
    Posts
    6,305
    cPanel/Enkompass Access Level

    Root Administrator

    Default Re: mail() funtion in php not sending email, not producing error

    You would need to have root SSH access to the machine to view the exim logs. All of the main server logs are unavailable in File Manager for cPanel accounts and only available for the root level user in SSH.

    If you do not have root access to the machine, you would need to contact your hosting provider for assistance with this issue.
    cPResources: Support Options | More Support Options | Forums Search | cPanel.net Site Search | Mailing Lists(Alt) | Docs
    -- Tristan, Forums Technical Analyst, cPanel Tech Support

    Submit a ticket | Check an existing ticket

  5. #5
    Member
    Join Date
    May 2011
    Posts
    11

    Default Re: mail() funtion in php not sending email, not producing error

    Thanks again for your reply. I've logged in as root, and checked the exim_mainlog file. There's quite a lot in there, and I'm not sure what's relevant.

    The first bit is:

    2011-05-08 04:02:04 pid 22590: SIGHUP received: re-exec daemon
    2011-05-08 04:02:04 exim 4.69 daemon started: pid=22590, -q1h, listening for SMTP on port 25 (IPv6 and IPv4) and for SMTPS on port 465 (IPv6 and IPv4)
    2011-05-08 04:02:04 Start queue run: pid=10218
    2011-05-08 04:02:04 pid 22590: SIGHUP received: re-exec daemon
    2011-05-08 04:02:04 1QIywE-0002am-3y Spool file is locked (another process is handling this message)
    2011-05-08 04:02:04 1QI1ja-0003nJ-9L == apps+197503443604710.547119812.17215...l.facebook.com routing defer (-51): retry time not reached
    2011-05-08 04:02:04 End queue run: pid=10218
    2011-05-08 04:02:04 exim 4.69 daemon started: pid=22590, -q1h, listening for SMTP on port 25 (IPv6 and IPv4) and for SMTPS on port 465 (IPv6 and IPv4)
    2011-05-08 04:02:04 pid 22590: SIGHUP received: re-exec daemon
    2011-05-08 04:02:04 exim 4.69 daemon started: pid=22590, -q1h, listening for SMTP on port 25 (IPv6 and IPv4) and for SMTPS on port 465 (IPv6 and IPv4)
    2011-05-08 04:02:04 Start queue run: pid=10225
    2011-05-08 04:02:04 1QI1ja-0003nJ-9L == apps+197503443604710.547119812.17215...l.facebook.com routing defer (-51): retry time not reached
    2011-05-08 04:02:04 1QIywG-0002ef-A9 Spool file is locked (another process is handling this message)
    2011-05-08 04:02:04 1QIywE-0002am-3y Spool file is locked (another process is handling this message)
    2011-05-08 04:02:04 End queue run: pid=10225
    2011-05-08 04:02:04 1QIywG-0002ef-A9 <= <> R=1QIywE-0002am-3y U=mailnull P=local S=4565
    2011-05-08 04:02:04 1QIywG-0002ef-A9 User 0 set for local_delivery transport is on the never_users list
    2011-05-08 04:02:04 1QIywG-0002ef-A9 == root@main.pubfish.com R=localuser T=local_delivery defer (-29): User 0 set for local_delivery transport is on the never_users list
    2011-05-08 04:02:04 1QIywG-0002ef-A9 ** root@main.pubfish.com: retry timeout exceeded
    2011-05-08 04:02:04 1QIywG-0002ef-A9 root@main.pubfish.com: error ignored
    2011-05-08 04:02:04 1QIywE-0002am-3y Completed
    2011-05-08 04:02:04 1QIywG-0002ef-A9 Completed
    I've no idea what any of this means! Can anyone help me out?

    Thanks!

  6. #6
    cPanel Staff cPanelTristan's Avatar
    Join Date
    Oct 2010
    Location
    somewhere over the rainbow
    Posts
    6,305
    cPanel/Enkompass Access Level

    Root Administrator

    Default Re: mail() funtion in php not sending email, not producing error

    Did you check the exim logs with the command I provided? The full logs won't be very meaningful, which is why you would exigrep for the exact email account:

    Code:
    exigrep myemailaddress@gmail.com /var/log/exim_mainlog
    This is the previously provided command you would use. You would replace myemailaddress@gmail.com with the real gmail address being used to send to from the script.
    cPResources: Support Options | More Support Options | Forums Search | cPanel.net Site Search | Mailing Lists(Alt) | Docs
    -- Tristan, Forums Technical Analyst, cPanel Tech Support

    Submit a ticket | Check an existing ticket

  7. #7
    Registered User
    Join Date
    Jul 2011
    Posts
    1

    Default Re: mail() funtion in php not sending email, not producing error

    I have the same iissue

    2011-07-01 20:25:50 1Qcpu2-0000xx-HF <= general@spangaloo.com U=spang P=local S=572
    2011-07-01 20:25:50 1Qcpu2-0000xx-HF => jamesb <jamesb@jambux.com> R=virtual_user T=virtual_userdelivery
    2011-07-01 20:25:50 1Qcpu2-0000xx-HF Completed


    that tells me it was sent but it never arrives

    this also happens when I send from a script and the destination is on the same server

    the list above is from using this
    exigrep myemailaddress@gmail.com /var/log/exim_mainlog

    I used Putty to access the server
    I have check the Nobody setting as well and it is set to off etc
    this is making me insane because I have
    2 servers running identical same Cpanel and WHM one sends mail and one does not
    This seems to be a recent event that it stopped working on the one server because it used to work
    Last edited by jammer699669; 07-01-2011 at 10:26 PM.

  8. #8
    Member
    Join Date
    Sep 2007
    Posts
    29

    Default Re: mail() funtion in php not sending email, not producing error

    I have same problem, but there no log even using exigrep. not all account can't send email

  9. #9
    cPanel Staff cPanelMichael's Avatar
    Join Date
    Apr 2011
    Posts
    1,346
    cPanel/Enkompass Access Level

    Root Administrator

    Default Re: mail() funtion in php not sending email, not producing error

    Hello

    It's difficult to pinpoint this to any specific error or configuration without access to the server. I suggest opening a support ticket so we can check further:

    Submit A Ticket

    You can post the ticket number here so we can share the solution when it's resolved.

    Thank you.
    cPResources: Support Options - Submit a ticket here - Additional Support Options - Forums Search - Mailing Lists - Documentation - Migration Services
    -- cPanelMichael - Migration Specialist, Technical Analyst, cPanel Technical Support

Similar Threads & Tags
Similar threads

  1. ForceType producing 500 Error on Apache 1.3
    By awells in forum cPanel and WHM Discussions
    Replies: 18
    Last Post: 12-23-2006, 12:43 AM
  2. [WHM - API] E-mail Address Funtion
    By getlowdogg369 in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 08-10-2006, 02:32 AM
  3. php mail() function not sending mail
    By fuzzymonkey in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 02-26-2006, 10:49 AM
  4. Pop Email Not Receiving Mail or Sending Mail
    By demine0 in forum cPanel and WHM Discussions
    Replies: 4
    Last Post: 01-14-2006, 09:53 AM
  5. Email Filtering - Sending mail to a PHP script.
    By uamistad in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 01-26-2005, 02:40 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube