warning: mail(): Multiple or malformed

I would like to send mail using php mail function. so wrote the code for execute the function. unfortunately i got the error instead of success when i execute the mail function. I don’t know what i did wrong on the code to execute. This is my code

$to = 'johndoe@example.com';
$subject = 'Your subject';
$header = "From: ".$_POST['career_name']." <".$_POST['career_email'].">\n";
$header .= "Reply-To: ".$to."\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed; boundary=\"".$num."\"\n\n";
$header .= "--".$num."\n";
$header .= "Content-type:text/html; charset=iso-8859-1\n";
$header .= "Content-Transfer-Encoding: 7bit\n\n";
$header .= $message."\n\n";
$header .= "--".$num."\n";
$header .= "Content-Type: application/octet-stream; name=\"".$strresume_name."\"\n";
$header .= "Content-Transfer-Encoding: base64\n";
$header .= "Content-Disposition: attachment; filename=\"".$strresume_name."\"\n\n";
$header .= $data."\n\n";
$header .= "--".$num."--";
if (!empty($_POST['career_name']) && !empty($_POST['career_email'])) {
if (filter_var($_POST['career_email'], FILTER_VALIDATE_EMAIL)) {
mail($to, $subject, $message, $header);

echo "mail sent"
}
} else {
echo "mail failed";
}

Solution: I was trying to send message body as headers on my code. finally, i have corrected the code. check it below.

$header = "From: ".$_POST['career_name']." <".$_POST['career_email'].">\n";
$header .= "Reply-To: ".$to."\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed; boundary=\"".$num."\"\n\n";
$emessage = "--".$num."\n";
$emessage .= "Content-type:text/html; charset=iso-8859-1\n";
$emessage .= "Content-Transfer-Encoding: 7bit\n\n";
$emessage .= $message."\n\n";
$emessage .= "--".$num."\n";
$emessage .= "Content-Type: application/octet-stream; name=\"".$strresume_name."\"\n";
$emessage .= "Content-Transfer-Encoding: base64\n";
$emessage .= "Content-Disposition: attachment; filename=\"".$strresume_name."\"\n\n";
$emessage .= $data."\n\n";
$emessage .= "--".$num."--";
if (!empty($_POST['career_name']) && !empty($_POST['career_email'])) {
if (filter_var($_POST['career_email'], FILTER_VALIDATE_EMAIL)) {
mail($to, $subject, $emessage, $header);

echo "mail sent"
}
} else {
echo "mail failed";
}