How can PHP be used to send emails in HTML or text format?
To send emails in HTML or text format using PHP, you can use the `mail()` function along with setting the appropriate headers to specify the content type. To send an HTML email, you need to set the `Content-Type` header to `text/html`. To send a plain text email, set the `Content-Type` header to `text/plain`.
// Send HTML email
$to = 'recipient@example.com';
$subject = 'HTML Email Test';
$message = '<html><body><h1>Hello, this is an HTML email!</h1></body></html>';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail($to, $subject, $message, $headers);
// Send plain text email
$to = 'recipient@example.com';
$subject = 'Text Email Test';
$message = 'Hello, this is a plain text email!';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/plain; charset=iso-8859-1' . "\r\n";
mail($to, $subject, $message, $headers);