我正在使用SparkPost PHP API发送电子邮件给收件人,但我面临这个错误。目前我已经建立了所有必要的领域,但我仍然遇到大型电子邮件的问题。我可以轻松发送小文本,但我在大数据方面遇到困难。SparkPost发送电子邮件模板
[{"message":"required field is missing","description":"At least one of 'text' or 'html' needs to exist in 'content'","code":"1400"}]
我的代码是:
for ($j = 0; $j < count($result1arr); $j++) {
try {
SparkPost::setConfig(["key" => "XXXXX"]);
$results = Transmission::send(array(
"from" => "[email protected]",
"html" => $resultarr['mailBody'],
"text" => $resultarr['mailBody'],
"subject" => $resultarr['subject'],
"recipientList" => $result1arr[$j]['groupName']
));
$_SESSION['success_message'] = 'Email sended successfully to Recipient List with ID : ' . $data['recipients_id'];
$qry = "DELETE from mailQueue where mailQueueId={$result1arr[$j]['mailQueueId']}";
$res = $conn->query($qry);
$sql1 = "INSERT INTO sendMailHistory (schoolName,noOfMailSent) VALUES ('{$result1arr[$j]['originalGroupId']}','{$results['results']['total_accepted_recipients']}')";
$result1 = $conn->query($sql1);
$chc = curl_init();
curl_setopt($chc, CURLOPT_URL, "https://api.sparkpost.com/api/v1/recipient-lists/{$result1arr[$j]['groupName']}");
curl_setopt($chc, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($chc, CURLOPT_HEADER, FALSE);
curl_setopt($chc, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($chc, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($chc, CURLOPT_HTTPHEADER, array(
"Accept: application/json",
"Authorization: XXXXX"
));
$response = curl_exec($chc);
curl_close($chc);
header('Location: ../index.php');
exit;
return true;
} catch (\Exception $exception) {
echo $exception->getMessage();
}
}
我删除从问题的API密钥,但你应该删除键,创建一个新的:/ – cfs
什么是失败的电子邮件大概有多大?我认为小信息和大邮件之间的一切都是一样的? – Yepher
你还有问题Bindesh? – Jordan