php mail() function not working

nowashburn

Registered
Dec 11, 2008
2
0
51
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 = "[email protected]_______.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "[email protected]";
$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?
 

nowashburn

Registered
Dec 11, 2008
2
0
51
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?
 

rhenderson

Well-Known Member
Apr 21, 2005
785
2
168
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.