PHP发送电子邮件

I tried to send an email vie PHP but got nothing. I don't see what I am doing wrong.

// Send an email.
$subject = 'Welcome to mypage';
$message = 'your registration went fine.';
echo $email;  
$a=mail($email, $subject, $message );
echo 'Mail sent, a='.$a;  

I checked that $email contains my email address and $a = 1 after running the code. Still my mailbox is empty. Why?

You probably don't have Apache configured correctly. That's why the email isn't sending.

Some mail servers require mail headers:

$header  = "MIME-Version 1.0
"; 
$header .= "Content-type: text/plain; charset=iso-8859-1
"; 
$header .= "From: ".$sendername." <".$fromemail.">
";
$header .= "X-Mailer: PHP/".phpversion();

mail($email, $subject, $message, $header);