What are potential issues when using PHP mail() function to send emails, especially when dealing with multiple recipients?
One potential issue when using the PHP mail() function to send emails to multiple recipients is that some email clients may mark the email as spam if the headers are not properly formatted. To solve this issue, you can use the "Bcc" header to send the email to multiple recipients without exposing their email addresses to each other.
$to = "recipient1@example.com, recipient2@example.com";
$subject = "Test Email";
$message = "This is a test email sent to multiple recipients using Bcc.";
$headers = "From: sender@example.com\r\n";
$headers .= "Bcc: recipient1@example.com, recipient2@example.com\r\n";
mail($to, $subject, $message, $headers);