What are the differences between using CC and multiple recipients in PHP email functions?

When sending emails in PHP, using the "CC" field allows you to send a copy of the email to additional recipients without them being visible to the main recipient. On the other hand, adding multiple recipients directly in the "To" field will make all recipients visible to each other. It is generally recommended to use the "CC" field for sending copies of the email to multiple recipients while keeping their identities private.

$to = "mainrecipient@example.com";
$cc = "recipient1@example.com, recipient2@example.com";

$subject = "Hello";
$message = "This is a test email";

$headers = "From: sender@example.com\r\n";
$headers .= "CC: $cc\r\n";

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