我正在使用https://github.com/abishekrsrikaanth/mailto在 mandrill 中处理我的电子邮件的包。该软件包有一个方法来安排这样的电子邮件。
$timestamp = new DateTime('+1 hour');
$mandrill = MailTo::Mandrill();
$mandrill->addRecipient($email, $name)
->setFrom($email, $name)
->setHtml($html)
->setText($text)
->setSubject($subject)
->send($timestamp);
但我找不到取消预定电子邮件的方法。我读了这个文档 https://mandrillapp.com/api/docs/messages.JSON.html#method=cancel-scheduled
请求 JSON
{
"key": "example key",
"id": null
}
但我不知道如何实现这个。有人可以帮我解决这个问题吗?
最佳答案
您可以使用官方的 Mandrill PHP SDK,因为 MailTo 包中没有实现取消预定电子邮件的方法。
<?php
try {
$mandrill = new Mandrill('YOUR_API_KEY');
$id = 'YOUR-MESSAGE-ID'; // id of scheduled message to be cancelled
$result = $mandrill->messages->cancelScheduled($id);
print_r($result);
} catch(Mandrill_Error $e) {
echo 'A mandrill error occurred: ' . get_class($e) . ' - ' . $e->getMessage();
throw $e;
}
?>
这是有关 https://mandrillapp.com/api/docs/messages.php.html#method-cancel-scheduled 的信息
您只需传递消息 ID,它将从计划的消息队列中删除。您很可能会在计划调用的响应中获得消息 ID。
以下是设置 SDK 的详细信息 https://mandrillapp.com/api/docs/index.php.html
关于php - 如何取消mandrill中预定的电子邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30068221/