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() not sending on my server! helppp!

Discussion in 'E-mail Discussions' started by pikuser5, Mar 3, 2010.

  1. pikuser5

    pikuser5 Member

    Joined:
    Mar 3, 2010
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    hi
    I have a strange problem on my server.
    php mail() function does not send emails.
    The Prevent the user "nobody" from sending out mail to remote addresses is OFF.
    What can I do? :confused::confused:
    I have cPanel 11.25.0-S43473 ...
    thank's
     
  2. thewebhosting

    thewebhosting Well-Known Member

    Joined:
    May 9, 2008
    Messages:
    1,201
    Likes Received:
    1
    Trophy Points:
    38
    Please make sure that mail() is not blocked in your php.ini file.
     
  3. pikuser5

    pikuser5 Member

    Joined:
    Mar 3, 2010
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    mail() in the php ini file is ok...
    from scripts like joomla emails working ok and use the php mail function... :(

    I think that the server does not like emails from this script ...
    mail($shopper_email,$shopper_subject,$shopper_message);

    What can I do?
     
    #3 pikuser5, Mar 3, 2010
    Last edited: Mar 3, 2010
  4. sneakyimp

    sneakyimp Member

    Joined:
    Mar 3, 2010
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    mail is tricky because the failure could be anywhere in a long chain of processes. you should start by checking for the success or failure of your call to the mail function.

    You may also find this thread useful as it discusses the points of failure and options other than the php mail func.
     
  5. pikuser5

    pikuser5 Member

    Joined:
    Mar 3, 2010
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    the script is ok because it works on another server ... ! :(
    ... :confused: ...
    anyone has any idea?
     
  6. sneakyimp

    sneakyimp Member

    Joined:
    Mar 3, 2010
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    If it was ok you wouldn't be posting here. :)

    You should always check the result of the mail function just in case it returns FALSE. From the documentation:
    If your mail function returns FALSE then you would KNOW there's a problem with your mail configuration. If it returns TRUE then there could still be something wrong with your mail configuration. You would need to check the mail log in either case to see if you are getting any errors.

    The kicker is that php may be handing off the mail, your server may be sending off the mail, and it may get spam filtered along the way.

    I would highly recommend checking out that best practices thread.
     
  7. veronicabend

    veronicabend Well-Known Member

    Joined:
    Feb 25, 2005
    Messages:
    52
    Likes Received:
    0
    Trophy Points:
    6
    You could try explicitly setting the From address using the -f parameter, as explained in example #3 in the php.net manual page for mail:

    PHP:
    <?php
    mail
    ('nobody@example.com''the subject''the message'null,
       
    '-fwebmaster@example.com');
    ?> 
    This once worked for me.
     
  8. pikuser5

    pikuser5 Member

    Joined:
    Mar 3, 2010
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    thank'sssss!!!!!!!!!!!!!!! now work's!!!!!!!!!!! :cool:
     
  9. Zenonline

    Zenonline Registered

    Joined:
    Mar 2, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Sorry for resurrecting an old thread but I am a complete noob on this stuff and confused!

    Why does using
    PHP:
    <?php 
    mail
    ('nobody@example.com''the subject''the message'null
       
    '-fwebmaster@example.com'); 
    ?>
    work? what does the
    PHP:
    '-f'
    actually do?

    The reason why I am asking is that I have just started using a VPS and my previous code worked fine and then it just stopped... I did a re-image hoping that would solve the problem and it didn't.

    the code I was using was from excerpt 2 from php.net on mail
    PHP:
    <?php
    $to      
    'nobody@example.com';
    $subject 'the subject';
    $message 'hello';
    $headers 'From: webmaster@example.com' "\r\n" .
        
    'Reply-To: webmaster@example.com' "\r\n" .
        
    'X-Mailer: PHP/' phpversion();

    mail($to$subject$message$headers);
    ?>
    This new -f bit of code does solve it but I don't want to be ignorant, I know I have a mountain of info to climb to understand linux but I have got to start somewhere...

    Examining the email, it seems whatever comes after the "-f" comes up as the actual sender (when going through the internet headers) whereas nobody@example.com comes up in the From field in the email client.

    Also what could have happened to my server for the original code from working (also mysql connection flipped out as well... I could connect to the database but not see any tables)?

    cheers

    Zen
     
Loading...

Share This Page