title: MailGun 401 response forbidden where am i going wrong
body: <p>I have 2 scripts for mailgun api the one i wrote returns 401 forbidden the one i found online works perfect i tried both with the same domain/api key
  this one works copy paste from github gist</p>
  
  <p><strong>this one works like a charm</strong></p>
  
  <pre><code>&lt;?php
  function send_mailgun($email, $body) {
      $domain = "SendingDomain";
      $config = array();
      $config['api_key'] = "key-mailgunkey";
      $config['api_url'] = "https://api.mailgun.net/v3/" . $domain . "/messages";
      $message = array();
      $message['from'] = "Mailgun &lt;user@SendingDomain&gt;";
      $message['to'] = $email;
      $message['h:Reply-To'] = "&lt;user@SendingDomain&gt;";
      $message['subject'] = "Eye-Catching Subject Line";
      $message['html'] = $body;
      $curl = curl_init();
      curl_setopt($curl, CURLOPT_URL, $config['api_url']);
      curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
      curl_setopt($curl, CURLOPT_USERPWD, "api:{$config['api_key']}");
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
      curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
      curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
      curl_setopt($curl, CURLOPT_POST, true);
      curl_setopt($curl, CURLOPT_POSTFIELDS, $message);
      $result = curl_exec($curl);
      curl_close($curl);
      return $result;
  }
  echo send_mailgun("personal@domain.com", "Body of the message here!");
  ?&gt;
  </code></pre>
  
  <p><strong>And this one doesn't work</strong></p>
  
  <pre><code>&lt;?php
  $to = "&lt;personal@domain.com&gt;";
  #$bcc = null;
  $replyTo = "&lt;dinner@sendingdoamin&gt;";
  #$tag = "tag";
  $subject = "subject";
  #$text = "HI Test \n\r.";
  $html ="&lt;h1&gt;hi&lt;/h1&gt;";
  $fromUser ='hi &lt;user@';
  $domain = 'domain';
  
      #$filePath=!empty($img)?curl_file_create($img):null;
      $dataSubmit=array(
          'from'  =&gt; $fromUser.$domain.'&gt;',
          'to'    =&gt; $to,
          #'bcc'  =&gt; $bcc,
          #'o:tag'    =&gt; $tag,
          #'text' =&gt; $text,
          'h:Reply-To'    =&gt; $replyTo,
          'subject'   =&gt; $subject,
          'html'  =&gt; $html,
          #'inline[1]'    =&gt; $filePath,
          #'attachment[1]'    =&gt; $filePath
      );
      echo '&lt;pre&gt;';
      print_r($dataSubmit);
  $service_url = 'https://api.mailgun.net/v3/'.$domain.'/messages';
  var_dump($service_url);
  $curl = curl_init();
  curl_setopt($curl, CURLOPT_URL,$service_url);
  curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  curl_setopt($curl, CURLOPT_USERPWD, 'key-mailgunkey'); 
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($curl, CURLOPT_TIMEOUT, 45);
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); 
  curl_setopt($curl, CURLOPT_POST, true);
  curl_setopt($curl, CURLOPT_POSTFIELDS, $dataSubmit);
  $result = curl_exec($curl);
  $info = curl_getinfo($curl);
      curl_close($curl);
      var_dump($result);
      var_dump($info);
  
  
   ?&gt;
  </code></pre>
  
  <p>as you can see i commented out the differences i found made sure they have the same curl options and one works the other doesn't.</p>