通过 sendgrid 循环发送的电子邮件只发送一封

emails by sendgrid in a loop sending only one

我正在向所有未通过 sndgrid 电子邮件验证其电子邮件的最近会员发送电子邮件 api

进程有一个循环,大约有 56 个成员,也可能更少 这是代码

    $getall_NOW_joins=mysqli_query($connection,"select name,email from members
    where (some code) order by id desc limit 53");
     while($theEMAILS=mysqli_fetch_array($getall_NOW_joins)){
      $EMAILesee=$theEMAILS['email'];
    $messageto90="<body>some html...... </body>"
          $subject09="Verify email - domain";
        $json_string = array( 'to' => array("$EMAILesee"),'category' => 'cron_rec_m');
       $tos=$EMAILesee;
       include_once('emailapi.php');
       echo $response."<br/>";
        }

页面电子邮件api包含

  <?php

    $url = 'https://api.sendgrid.com/';
   $user = 'some';
     $pass = 'thing';
   $params = array(
  'api_user'  => $user,
  'api_key'   => $pass,
  'x-smtpapi' => json_encode($json_string),
'to'        => "$tos",
'subject'   => "$subject09",
'html'      => "$messageto90",
'from'      => "domain.com<contact@domain.com>",
 );


  $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);
    ?>

问题是页面只发送一封电子邮件,这是循环中的第一封电子邮件,其他电子邮件未发送请帮我找到错误
我在 cron 作业中使用此页面

可能是因为您正在使用 include_once('emailapi.php');。将其更改为 include.