1
打招呼sendgrid的所有我有問題發送多個收到電子郵件API問題 實際上是API接受這個數組sendgrid發送多個回執電子郵件
<?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<[email protected]>",
);
$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'
);
它發送,但有問題m是我通過mysql從我的數據庫中獲取電子郵件如何將電子郵件直接放入數組中,我正在使用循環和 將獲取的電子郵件存儲到$ emailfinallist變量中,並將此變量傳遞給$ json_string數組,但那dosent工程....
怎麼做我把郵件直接進入此陣