What are common pitfalls when sending HTML emails using PHP?

One common pitfall when sending HTML emails using PHP is not setting the correct Content-Type header. This can result in the email being displayed as plain text instead of formatted HTML. To solve this issue, make sure to set the Content-Type header to "text/html" when sending HTML emails.

// Set the Content-Type header for HTML emails
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

// Send the email
mail($to, $subject, $message, $headers);