How can PHP be used effectively to send emails with proper headers and formatting?
To send emails with proper headers and formatting in PHP, you can use the built-in `mail()` function along with additional headers like `From`, `Reply-To`, `Content-Type`, and `MIME-Version`. This allows you to specify the sender, reply-to address, content type, and MIME version for the email.
$to = "recipient@example.com";
$subject = "Test Email";
$message = "This is a test email.";
$headers = "From: sender@example.com\r\n";
$headers .= "Reply-To: sender@example.com\r\n";
$headers .= "Content-Type: text/html; charset=UTF-8\r\n";
$headers .= "MIME-Version: 1.0\r\n";
mail($to, $subject, $message, $headers);