How can a PHP script be used to send emails to arbitrary email addresses specified in a form?

To send emails to arbitrary email addresses specified in a form using PHP, you can use the `mail()` function in PHP. You need to retrieve the email addresses from the form submission, sanitize them to prevent injection attacks, and then loop through each email address to send the email.

<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $to = $_POST['email']; // Retrieve email addresses from the form
    $subject = "Subject of the email";
    $message = "Message content of the email";
    $headers = "From: your@example.com";

    // Sanitize the email address to prevent injection attacks
    $to = filter_var($to, FILTER_SANITIZE_EMAIL);

    // Loop through each email address and send the email
    foreach ($to as $email) {
        mail($email, $subject, $message, $headers);
    }
}
?>