title: mailgun send email to multiple users
body: <p>i have the following mailgun.php file:</p>
  
  <pre><code>define('MAILGUN_URL', 'https://api.eu.mailgun.net/v3/my_domain');
  define('MAILGUN_KEY', 'xxxxxxxxx'); 
  function sendmailbymailgun($to,$toname,$mailfromnane,$mailfrom,$subject,$html,$text,$tag,$replyto){
      $array_data = array(
          'from'=&gt; $mailfromnane .'&lt;'.$mailfrom.'&gt;',
          'to'=&gt;$toname.'&lt;'.$to.'&gt;',
          'subject'=&gt;$subject,
          'html'=&gt;$html,
          'text'=&gt;$text,
          'o:tracking'=&gt;'yes',
          'o:tracking-clicks'=&gt;'yes',
          'o:tracking-opens'=&gt;'yes',
          'o:tag'=&gt;$tag,
          'h:Reply-To'=&gt;$replyto
      );
      $session = curl_init(MAILGUN_URL.'/messages');
      curl_setopt($session, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
      curl_setopt($session, CURLOPT_USERPWD, 'api:'.MAILGUN_KEY);
      curl_setopt($session, CURLOPT_POST, true);
      curl_setopt($session, CURLOPT_POSTFIELDS, $array_data);
      curl_setopt($session, CURLOPT_HEADER, false);
      curl_setopt($session, CURLOPT_ENCODING, 'UTF-8');
      curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($session, CURLOPT_SSL_VERIFYPEER, false);
      $response = curl_exec($session);
      curl_close($session);
      $results = json_decode($response, true);
      return $results;
  }
  </code></pre>
  
  <p>I am trying to send a notification email to end users with the following code:
  <code>$eml</code> = email address variable
  <code>$usrn</code> = user name
  <code>$htm</code> = html text generated from mailtext.php with displaytext function
  <code>$cust_orderid</code> = parameter,not really important in this case</p>
  
  <pre><code>if ((strlen($eml)&gt;5)&amp;&amp;(isset($eml))&amp;&amp;(!is_null($eml))) {
  include('./mailtext.php');
  $htm = displaytext($cust_orderid);       
  require_once('./mailgun.php');
  sendmailbymailgun($eml,$usrn,'NOTIFICATIONS','notify@mydomain.com','NOTIFICATION SUBJECT',$htm,'','','');
            }
  </code></pre>
  
  <p>everything works fine, until i have in <code>$eml</code>  field multiple email addresses separated with comma.
  then i got the following error message:
  'to' parameter is not a valid address. please check documentation</p>
  
  <p>i checked the documentation and it tells, that i can have multiple email addresses separated by comma. reference:
  <a href="https://documentation.mailgun.com/en/latest/api-sending.html#sending" rel="nofollow noreferrer">mailgun API documentation</a></p>
  
  <p>some ideas how to solve this problem?</p>
  
  <p>thanks in advance</p>