Add multiple recipients in mail message php using mail function

In PHP, the mail() function allows you to specify multiple recipients by separating their email addresses with commas. Here's an example:

$to = '[email protected], [email protected], [email protected]';
$subject = 'Test email with multiple recipients';
$message = 'This is a test email sent to multiple recipients';

$headers = 'From: [email protected]'. "\r\n".
           'Reply-To: [email protected]'. "\r\n".
           'MIME-Version: 1.0'. "\r\n".
           'Content-Type: text/plain; charset=UTF-8';

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

In this example, the $to variable contains a comma-separated list of email addresses, and the mail() function will send the email to all of them.

Note that you can also use an array of email addresses instead of a comma-separated string:

$recipients = array('[email protected]', '[email protected]', '[email protected]');
$to = implode(',', $recipients);

//... rest of the code remains the same...

This can be useful if you need to dynamically generate the list of recipients or if you want to use a more readable format.

Also, keep in mind that the mail() function has some limitations, such as not supporting internationalized domain names (IDNs) or non-ASCII characters in the email addresses. If you need to send emails with more complex requirements, you may want to consider using a more advanced email library or service.