i am very beginner of PHP. i am trying to use mail function with differnt type of web server, the code is bellow

<?php
$to = "[email protected]";
$from = "[email protected]";
$subject = "This is a test email";
$message = "Dear John,\n\nThis is a fake email, I hope you enjoy it.\n\nFrom Jane.";

$headers = "From: $from\r\n";

$success = mail($to, $subject, $message, $headers);
if ($success)
echo "The email to $to from $from was successfully sent";
else
echo "An error occurred when sending the email to $to from $from";
?>
i know this is correct code, but it didnto work with many web server . at last its works at bizhat web server.
now my question is : is there any server configeration needed to use this mail function ??
like send mail path or localhost path,
pls help me to find out this problem