toniknik1982 wrote:mail() function in PHP won't work
I'm guessing the mail wont send? And since there is no error reported by you, your mail server must be setup correctly. Just incase i'm wrong, do you receive any error messages?
Code: Select all
<?php
// to test if the mail function does indeed function
mail($to,$subject,$message,$headers) or die('Mail not sent');
//
$to = "myemail@yahoo.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "somebody@gmail.com";
// changed this header
$headers = "From: " . $from;
mail($to,$subject,$message,$headers) or die('Mail not sent');
?>
Try the above code; you'll see i only modified the
$headers variable by adding a space after the colon, this is what most of the examples look like (ones i found). Lastly, use the PHP Code button to wrap your php code, it makes reading the code alot easier than a different color
Hth