What is the difference between sending a text email and an HTML email in PHP?

Sending a text email involves sending a plain text message without any formatting, while sending an HTML email allows for the inclusion of HTML tags to format the content with styles, images, links, etc. To send an HTML email in PHP, you need to set the appropriate headers and format the message content with HTML tags.

$to = 'recipient@example.com';
$subject = 'HTML Email Test';
$message = '<html><body>';
$message .= '<h1>Hello!</h1>';
$message .= '<p>This is an HTML email test.</p>';
$message .= '</body></html>';

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";

mail($to, $subject, $message, $headers);