title: Json response giving an error of Invalid email address using PHP GET method in sendgrid api
body: <p>i'm using sendgrid api for sending emails. when i'm trying to send a signle email then it's working fine &amp; when i'm trying to send mutiple email id's mannualy then it's also working fine.<br/>
  But the problem is when i' requesting email from database and wanna send it throught api,the json response giving me an error or invalid email address.
  <br/>
  Screenshot: <a href="https://prnt.sc/ph6i2n" rel="nofollow noreferrer">https://prnt.sc/ph6i2n</a></p>
  
  <p>below are my codes:</p>
  
  <pre><code>&lt;?php
  include_once "config/connect.php";
  $eid=$_REQUEST['eid'];
  $q="Select * from email where eid='$eid'";
  $qr=mysqli_query($mysql,$q) or die($q.mysqli_error($mysql));
  while($r=mysqli_fetch_object($qr))
  {
      $id       = $r-&gt;id;
      $emails   = $r-&gt;email;
      $message1 = $r-&gt;body;
      $subject1 = $r-&gt;subject;
      $attechment = $r-&gt;attechment;
  }
  
  $url = 'https://api.sendgrid.com/';
  $user = 'username';
  $pass = 'password';
  
  $fileName = $attechment;
  //$filePath = dirname('/uploads/attechment');
  $filePath = 'http://localhost/projects5/crm1/folder/dash/uploads/attechment';
  //$list = array('$emails');
  
  
  
  $json_string = array(
  
    'to' =&gt; array($emails),
    'category' =&gt; 'test_category'
  );
  
  
  $params = array(
      'api_user'  =&gt; $user,
      'api_key'   =&gt; $pass,
      'to'        =&gt; $emails,
      'x-smtpapi' =&gt; json_encode($json_string), 
      'subject'   =&gt; $subject1,
      'html'      =&gt; '&lt;p&gt; the HTML &lt;/p&gt;',
      'text'      =&gt; 'the plain text',
      'from'      =&gt; 'example@wephyre.com',
      //'files['.$fileName.']' =&gt; '@'.$filePath.'/'.$fileName
     'files['.$fileName.']' =&gt; file_get_contents($filePath.'/'.$fileName)
    );
  
  print_r($params);
  
  $request =  $url.'api/mail.send.json';
  
  // Generate curl request
  $session = curl_init($request);
  
  // Tell curl to use HTTP POST
  curl_setopt ($session, CURLOPT_POST, true);
  
  // Tell curl that this is the body of the POST
  curl_setopt ($session, CURLOPT_POSTFIELDS, $params);
  
  // Tell curl not to return headers, but do return the response
  curl_setopt($session, CURLOPT_HEADER, false);
  // Tell PHP not to use SSLv3 (instead opting for TLS)
  curl_setopt($session, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
  curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
  
  // obtain response
  $response = curl_exec($session);
  curl_close($session);
  
  // print everything out
  print_r($response);
  
  ?&gt;
  </code></pre>