The PHP mail() function is great for sending plain text emails but it will not send HTML emails without special headers.
Here is a PHP mail() with HTML example:
$body_html = '
<html>
<head>
<title>HTML Test Email</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p>
This is a test.
</p>
</body>
</html>
';
$from = 'sender@example.com';
$to = 'recipient@example.com';
$subject = 'HTML Test Email';
$headers = "From:$from\n" .
"MIME-Version: 1.0\n" .
"Content-type: text/html; charset=iso-8859-1";
mail($to, $subject, $body_html, $headers);
Demo
Demo Send HTML Email with PHP and mail()






















Is this part necessary? mail($to, $subject, $body_html, $headers);
Without the mail function the email will not be sent.