当邮件使用Mailgun的官方PHP SDK成功排队时,如何读取API响应?



我非常困惑,当邮件使用Mailgun的官方PHP SDK(2.8(成功排队时,如何读取API响应。

// First, instantiate the SDK with your API credentials
$mg = Mailgun::create('key-example'); // For US servers
$mg = Mailgun::create('key-example', 'https://api.eu.mailgun.net'); // For EU servers
// Now, compose and send your message.
// $mg->messages()->send($domain, $params);
$response = $mg->messages()->send('example.com', [
'from'    => 'bob@example.com',
'to'      => 'sally@example.com',
'subject' => 'The PHP SDK is awesome!',
'text'    => 'It is so simple to send a message.'
]);
var_dump($response);
//Var dump results
object(MailgunModelMessageSendResponse)#130 (2) {
["id":"MailgunModelMessageSendResponse":private]=>
string(52) "<201949588013742.1.5234966234A248269@mydomain.com>"
["message":"MailgunModelMessageSendResponse":private]=>
string(18) "Queued. Thank you."
}

$response是一个私有对象,我无法读取"已排队。谢谢。我在文档中找不到任何相关的函数来执行此操作。我在这里错过了什么吗?

你可以通过这个得到以下数据

对于 ID:$response->getId()

对于消息:$response->getMessage()

干杯

最新更新