What are common pitfalls when sending emails to multiple recipients in PHP scripts?

One common pitfall when sending emails to multiple recipients in PHP scripts is accidentally exposing all recipients' email addresses by including them in the "To" or "Cc" fields. To avoid this, it's recommended to use the "Bcc" field to hide recipients' email addresses from each other.

$to = 'recipient1@example.com, recipient2@example.com';
$subject = 'Subject';
$message = 'Email message';
$headers = 'From: sender@example.com' . "\r\n";
$headers .= 'Bcc: hiddenrecipient@example.com' . "\r\n";

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