Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Member
    Join Date
    Mar 2010
    Posts
    16

    Default php mail() not sending on my server! helppp!

    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?
    I have cPanel 11.25.0-S43473 ...
    thank's

  2. #2
    Member
    Join Date
    May 2008
    Posts
    1,203

    Default

    Please make sure that mail() is not blocked in your php.ini file.

  3. #3
    Member
    Join Date
    Mar 2010
    Posts
    16

    Default

    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?
    Last edited by pikuser5; 03-03-2010 at 04:12 PM.

  4. #4
    Member
    Join Date
    Mar 2010
    Posts
    7

    Default

    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. #5
    Member
    Join Date
    Mar 2010
    Posts
    16

    Default

    the script is ok because it works on another server ... !
    ... ...
    anyone has any idea?

  6. #6
    Member
    Join Date
    Mar 2010
    Posts
    7

    Default

    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:
    Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.

    It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination.
    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. #7
    Member
    Join Date
    Feb 2005
    Posts
    32

    Default

    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 Code:
    <?php
    mail
    ('nobody@example.com''the subject''the message'null,
       
    '-fwebmaster@example.com');
    ?>
    This once worked for me.

  8. #8
    Member
    Join Date
    Mar 2010
    Posts
    16

    Thumbs up

    Quote Originally Posted by veronicabend View Post
    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 Code:
    <?php
    mail
    ('nobody@example.com''the subject''the message'null,
       
    '-fwebmaster@example.com');
    ?>
    This once worked for me.
    thank'sssss!!!!!!!!!!!!!!! now work's!!!!!!!!!!!

  9. #9
    Registered User
    Join Date
    Mar 2011
    Posts
    1

    Default Re: php mail() not sending on my server! helppp!

    Sorry for resurrecting an old thread but I am a complete noob on this stuff and confused!

    Why does using
    PHP Code:
    <?php 
    mail
    ('nobody@example.com''the subject''the message'null
       
    '-fwebmaster@example.com'); 
    ?>
    work? what does the
    PHP Code:
    '-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 Code:
    <?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

Similar Threads & Tags
Similar threads

  1. php mail() not sending on my server! helppp!
    By pikuser5 in forum cPanel and WHM Discussions
    Replies: 6
    Last Post: 03-04-2010, 11:28 AM
  2. PHP not sending mail
    By desiguru in forum New User Questions
    Replies: 0
    Last Post: 12-08-2009, 07:13 PM
  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. PHP Mail Sending Problems
    By quortex in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 04-26-2005, 08:56 AM
  5. Problem with sending mail in PHP
    By khoonchee in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 04-10-2003, 06:19 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube