What are common issues when sending emails using PHP scripts?

Issue: One common issue when sending emails using PHP scripts is that the emails may end up in the recipient's spam folder. This can happen due to incorrect email headers or content that triggers spam filters. Solution: To avoid emails being marked as spam, make sure to set proper email headers, use a valid sender email address, and avoid using spam-triggering content in the email body.

<?php
$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 .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

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