sendgrid 发送多个收据电子邮件
sendgrid send multiple receipts email
你好,我在 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 数组,但是 dosent 有效....
如何将电子邮件直接放入此数组
看起来你传递的是字符串,而不是 'to' 参数中的变量:
'to' => array("$emailfinallist")
应该
'to' => $emailfinallist
您也在为 'subject' 和 'html' 参数做同样的事情。
你好,我在 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 数组,但是 dosent 有效....
如何将电子邮件直接放入此数组
看起来你传递的是字符串,而不是 'to' 参数中的变量:
'to' => array("$emailfinallist")
应该
'to' => $emailfinallist
您也在为 'subject' 和 'html' 参数做同样的事情。