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 not working

Discussion in 'E-mail Discussions' started by nowashburn, Dec 11, 2008.

  1. nowashburn

    nowashburn Registered

    Joined:
    Dec 11, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    trying to send out a simple email and it wont work on the cpanel server. tested a REALLY simple script on a few other servers without a problem. here is the php code im testing:

    <?php

    $to = "eric@_______.com";
    $subject = "Test mail";
    $message = "Hello! This is a simple email message.";
    $from = "someonelse@example.com";
    $headers = "From: $from";
    $worked = mail($to,$subject,$message,$headers);

    if($worked) {
    echo "Mail Sent.";
    } else {
    echo "Mail Not Sent.";
    }

    ?>

    any ideas on what is going on?
     
  2. nowashburn

    nowashburn Registered

    Joined:
    Dec 11, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    ok, i noticed that the script does work, but only when sending an email to an address on the same domain. how can i change this setting?
     
  3. rhenderson

    rhenderson Well-Known Member

    Joined:
    Apr 21, 2005
    Messages:
    785
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Oklahoma
    cPanel Access Level:
    Root Administrator
    I tried your script, change the info to email to a different server on a different network from our server and it worked fine, so the problem is not your script. It is most likely a setting on the server your using the script on.
     
Loading...

Share This Page