【发布时间】:2015-06-09 08:45:43
【问题描述】:
大家好,我在 sendgrid 的发送多个收据电子邮件 api 问题中遇到问题 实际上 api 接受这个数组
<?php
$url = 'https://api.sendgrid.com/';
$user = 'abc';
$pass = 'xyx';
$params = array(
'api_user' => $user,
'api_key' => $pass,
'x-smtpapi' => json_encode($json_string),
'to' => "$to",
'subject' => "$subject",
'html' => "$messaget",
'from' => "site.com<contact@site.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);
?>
问题来了
$json_string = array(
'to' => array(
"$emailfinallist"
),
'category' => 'test_category'
);
当我保持 json_string 一样时
$json_string = array(
'to' => array(
'email1','email2'
),
'category' => 'test_category'
);
它发送但问题是我通过 mysql 从我的数据库中获取电子邮件我如何将电子邮件直接放入数组中我正在使用循环和 将获取的电子邮件存储到变量 $emailfinallist 中,并将此变量传递给 $json_string 数组,但该变量有效....
我如何将电子邮件直接放入这个数组中
【问题讨论】:
标签: php mysql arrays email sendgrid