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

Discussion in 'E-mail Discussions' started by nichollsd, Sep 13, 2006.

  1. nichollsd

    nichollsd Member

    Joined:
    Aug 18, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Hi everyone,

    On the new server I'm working on, I can't seem to get the php mail() function to work properly. It was working fine on my old server, but now that I'm on this dedicated server it's not working. Is there something I need to set up in cPanel or WHM to enable this function to work properly?

    Thanks for any and all help you can give me!
     
  2. rsaylor

    rsaylor Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    160
    Likes Received:
    1
    Trophy Points:
    18
    make sure your hostname is valid and resolves. #1 reason for mail to fail to send.
     
  3. nichollsd

    nichollsd Member

    Joined:
    Aug 18, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    I'm sorry, I'm not quite sure what you mean by "hostname is valid and resolves". Sorry, but could you explain in a little more "newbie-friendly" terms?

    Thanks!
     
  4. rsaylor

    rsaylor Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    160
    Likes Received:
    1
    Trophy Points:
    18
    Hi, in WHM you have to set a hostname for your server. For example: server.mydomain.com

    A lot of people will use a fake name server. The name should be a verifiable name and should resolve. That's where I would check 1st.
     
  5. nichollsd

    nichollsd Member

    Joined:
    Aug 18, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Ok, I've found what you're talking about but everything seems to be set up right. The thing is, another site on the same server uses the same code and works properly, but for this site the function is not working properly. Is there anything else I should be doing/checking?
     
  6. Dennisb1

    Dennisb1 Active Member

    Joined:
    Aug 16, 2006
    Messages:
    27
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    The Netherlands
    its with php security
    open php.ini and look for a line
    Code:
    register_globals
    And make sure its turned on! when its off you cant send mail with php
    Php have register_globals a while ago turned off in there new installations read at:
    www.php.net/register_globals

    Good luck ;)
     
  7. rsaylor

    rsaylor Well-Known Member

    Joined:
    Mar 27, 2003
    Messages:
    160
    Likes Received:
    1
    Trophy Points:
    18
    you should then troubleshoot the mail logs,

    tail -f /var/log/exim_mainlog

    try sending a email, what error is logged. Look in /etc/httpd/logs/suexec_log , any errors for the site listed?

    Are permissions correct?
     
  8. nichollsd

    nichollsd Member

    Joined:
    Aug 18, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    I've made sure register globals is on, I've checked everything else, and everything seems fine but it's still not working.

    I've got 2 sites on the same server, and the function works on one of the sites but not on the other. would it have something to do with how I set the site up (the one I set up is the one where the php mail function isn't working, someone else set up the other site).

    I'm really stumped on this...if anyone has any more suggestions I could really use them!

    Thanks again!
     
  9. kistler

    kistler Well-Known Member

    Joined:
    Jan 27, 2005
    Messages:
    136
    Likes Received:
    0
    Trophy Points:
    16

    Is this true? as far as I know it should send with it off or on - I would tail your server:

    tail -f /var/log/exim_mainlog

    When you send mail using php it or something should show up there and will let you know why it stopped.

    Another thing is if you dont have phpsuexec it will send as nobody, you may have it disabled in WHM and if you dont sometimes you'll find that some other host will not like this. If you dont have phpsuexec installed I would do so.
     
    #9 kistler, Oct 11, 2006
    Last edited: Oct 11, 2006
  10. Ameer-AKA

    Ameer-AKA Registered

    Joined:
    Oct 13, 2006
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Ameer Aka
    Will your email be flagged as spam if it doesn't come from the same email address as the from: field?
     
  11. kistler

    kistler Well-Known Member

    Joined:
    Jan 27, 2005
    Messages:
    136
    Likes Received:
    0
    Trophy Points:
    16
    if it comes from "nobody" (if phpsuexec is not installed right) it more then likely will – Sometimes if that domain is not hosted at your server/ip it maybe marked as spam also do you have an rDNS setup on your ip?
     
Loading...

Share This Page