我发送电子邮件给所有未通过sndgrid email 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/>";
}
页面emailapi包含
<?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 job中使用这个页面
答案 0 :(得分:3)
这可能是因为你正在使用include_once('emailapi.php');
。将其更改为include
。