How can a While loop be used to send emails to multiple contacts in PHP?

To send emails to multiple contacts in PHP using a While loop, you can first store the list of contacts in an array. Then, iterate through the array using a While loop to send an email to each contact. Inside the loop, you can use the PHP `mail()` function to send the email.

<?php
$contacts = ['contact1@example.com', 'contact2@example.com', 'contact3@example.com'];

$subject = 'Test Email';
$message = 'This is a test email message.';

foreach ($contacts as $contact) {
    $headers = 'From: your_email@example.com';
    mail($contact, $subject, $message, $headers);
    echo "Email sent to: $contact <br>";
}
?>