Simple email function

I’m having trouble trying to email from PHP on my server. I’ve written a simple php function which should email me, but I never get an email from it. Is there something wrong in my code, or could there be something wrong with my server setup? Here’s the function:

<?php
$eol = "
";
$name = "Joe Bloggs";
$email = "joe@joebloggs.com";

$headers = "From: $name <$email>".$eol;
$headers .= "Reply-To: $name <$email>".$eol;
$headers .= "Return-Path: $name <$email".$eol;

mail($email,"test subject","test message body",$headers);

echo "email should have been sent to $email";
?>