PHP发送邮件功能不适用于其他网页[重复]

This question already has an answer here:

Something wrong with my codes?

<?php

 $rand_2 = "abcdefghijklmnopqeABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
 $rand_key = substr(str_shuffle($rand_2), 0, 30);


 $to = "meanlinsey@gmail.com";
 $subject = "Account Validation";
 $body = "Good Day! "."Mary Ann Linsey"."

 Copy this validation code below to 
 confirm your registration in Portal 

".$rand_key;
 $header = "From: Portal";



if(mail($to, $subject, $body, $header)){
    echo 'Message has been sent to: <strong>'.$to.'</strong>';
}else{
    echo 'something went wrong';
}

?>

some of my send email program is working this piece of codes is not I dont why I already configure the php.ini and send_mail.ini.

</div>
<?php

 $rand_2 = "abcdefghijklmnopqeABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
 $rand_key = substr(str_shuffle($rand_2), 0, 30);


 $to = "meanlinsey@gmail.com";
 $subject = "Account Validation";
 $body = "Good Day! "."Mary Ann Linsey"."

 Copy this validation code below to 
 confirm your registration in Portal 

".$randn_key;


 $headers ="Reply-To: \"".$name."\" <".$email_sender.">
";
$headers .="MIME-Version: 1.0
";
$headers .="From: \"".$name."\" <".$email_sender.">
";
$headers .="Content-Type: text/html; charset=utf-8
"; 



if(mail($to, $subject, $body, $headers)){
    echo 'Message has been sent to: <strong>'.$to.'</strong>';
}else{
    echo 'something went wrong';
}
?>