<pre><code>$email-&gt;cc = array(
    array('email' =&gt; 'cc1@example.com', 'name' =&gt; 'Person One'),
    // ...
);
</code></pre>

<p>If you want emails recipients to see other recipients listed in the email, use 'cc'; otherwise, use the loop as the other answer suggested, or 'bcc'.</p>

CC BY-SA 4.0
2019-01-15T04:42:16.460Z
2019-01-15T05:05:06.587Z
2019-01-15T05:05:06.587Z
Wei
<p>You can loop through a list of your recipients:</p>

<pre><code>// Comma-separated list of recipients
$recipients = 'person1@example.com, person2@example.com';

// Break out recipients into an array
$recipientList = explode( ",", $recipients );

// Create the globally known things about the EmailModel
$email = new EmailModel();
$email-&gt;subject = 'My Email Subject';
$email-&gt;body    = 'My Email Body';

// Loop through each recipient in the recipient list
foreach ( $recipientList as $recipient )
{
    try
    {
        // Add a specific recipient to the email model
        $email-&gt;toEmail = $recipient;

        // Send the email
        craft()-&gt;email-&gt;sendEmail( $email );
    }
    catch ( \Exception $e )
    {
        // Do nothing
        return false;
    }
}
</code></pre>

CC BY-SA 4.0
2018-06-20T22:13:04.707Z
Why not use cc?
Jason Galuten
CC BY-SA 3.0
2014-06-25T05:06:36.947Z
This worked perfectly! I'm a little bummed that "toEmail" is incapable of handling multiple email addresses (since the [PHP mail function](http://www.php.net/manual/en/function.mail.php) can handle multiple recipients with no problem), but your solution did the trick as a solid workaround. Thanks Ben!
Lindsey D
CC BY-SA 3.0
2014-06-25T01:10:11.147Z
2014-06-25T04:58:31.410Z
2014-06-25T04:58:31.410Z
Ben Parizek
<p>In my plugin, I'm sending an email like this:</p>

<pre><code>$recipients = 'person@example.com';

$email = new EmailModel();
$email-&gt;toEmail = $recipients;
$email-&gt;subject = 'My Email Subject';
$email-&gt;body    = 'My Email Body';

craft()-&gt;email-&gt;sendEmail($email);
</code></pre>

<p>Which works great! But when I'm sending to multiple people, the string would look like this...</p>

<pre><code>$recipients = 'person1@example.com, person2@example.com';
</code></pre>

<p>... and it generates an error:</p>

<pre><code>Invalid address: person1@example.com, person2@example.com
</code></pre>

<p><strong>How do I properly send an email to multiple recipients?</strong></p>

<plugin-development><emails>
How do I send an email to multiple recipients?
# How do I send an email to multiple recipients?

(Asked by: username_0 on 2014-06-25)

In my plugin, I'm sending an email like this:
$recipients = 'person@example.com';

$email = new EmailModel();
$email->toEmail = $recipients;
$email->subject = 'My Email Subject';
$email->body    = 'My Email Body';

craft()->email->sendEmail($email);

Which works great! But when I'm sending to multiple people, the string would look like this...
$recipients = 'person1@example.com, person2@example.com';

... and it generates an error:
Invalid address: person1@example.com, person2@example.com

How do I properly send an email to multiple recipients?

**Tags:** plugin-development, emails


---

## 2 answers

### Answer by username_2 on 2014-06-25. Score: 7 | Accepted answer

You can loop through a list of your recipients:
// Comma-separated list of recipients
$recipients = 'person1@example.com, person2@example.com';

// Break out recipients into an array
$recipientList = explode( ",", $recipients );

// Create the globally known things about the EmailModel
$email = new EmailModel();
$email->subject = 'My Email Subject';
$email->body    = 'My Email Body';

// Loop through each recipient in the recipient list
foreach ( $recipientList as $recipient )
{
    try
    {
        // Add a specific recipient to the email model
        $email->toEmail = $recipient;

        // Send the email
        craft()->email->sendEmail( $email );
    }
    catch ( \Exception $e )
    {
        // Do nothing
        return false;
    }
}

> **Comments:**
> **username_0**: This worked perfectly! I'm a little bummed that "toEmail" is incapable of handling multiple email addresses (since the [PHP mail function](http://www.php.net/manual/en/function.mail.php) can handle multiple recipients with no problem), but your solution did the trick as a solid workaround. Thanks Ben!  
> **username_3**: Why not use cc?  

---

### Answer by username_1 on 2019-01-15. Score: 1

$email->cc = array(
    array('email' => 'cc1@example.com', 'name' => 'Person One'),
    // ...
);

If you want emails recipients to see other recipients listed in the email, use 'cc'; otherwise, use the loop as the other answer suggested, or 'bcc'.


---

