I have a referral page where people can put in email addresses to send referrals out.

```
<form action="referemails.php" method="post">
Insert your friend's email below to refer them!<br><br>
Email: <input type="email" id="referemail" name="referemail[]" size="50" autofocus="autofocus" placeholder="example@email.com"><br>
Email: <input type="email" id="referemail" name="referemail[]" size="50" autofocus="autofocus" placeholder="example@email.com"><br>
Email: <input type="email" id="referemail" name="referemail[]" size="50" autofocus="autofocus" placeholder="example@email.com"><br>
  <input type="submit" value="Submit"></form>

```

The code for sending the emails are as follows:

```
<?php

if (isset($_POST['referemail'])) {
    $username= $_SESSION['username'];
    $options = array("options" => array(FILTER_FORCE_ARRAY));
    $email = filter_input(INPUT_POST, 'referemail', FILTER_SANITIZE_EMAIL, $options);
    $email = filter_var($email, FILTER_VALIDATE_EMAIL);
    if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
        // Not a valid email
        $error_msg = '<p class="error">The email address you entered is not valid</p>'; };

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: example@email.com' . "\r\n";
                        $to  = implode(',', $email);
                        $subject = 'Email!';
                        $message ='...';}

                           if (mail($to, $subject, $message, $headers)) { 
                               header('Location: ../includes/referfriends.php');
}
?>

```

I've tried a couple variations of the `implode(','` command. But either I'm not putting it in the right spot or, my theory, is that my filters on the $email is not letting multiple emails. It will send out the email if there is only one email address entered, but multiple emails it acts like it sent out though it didn't, and I get no errors in my log.
What did I miss or misplace that's blocking the multiple addresses? Thanks in advance for any knowledge or helpful links. I've tried searching the webz and tried multiple options but always get to this point.