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

How to read API response when a mail is successfully queued using Mailgun's official PHP SDK?

当使用 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(Mailgun\Model\Message\SendResponse)#130 (2) {
  ["id":"Mailgun\Model\Message\SendResponse":private]=>
  string(52) "<201949588013742.1.5234966234A248269@mydomain.com>"
  ["message":"Mailgun\Model\Message\SendResponse":private]=>
  string(18) "Queued. Thank you."
}

$response 是私有对象,我无法读取其中的 "Queued. Thank you."。我在文档中找不到任何相关功能来执行此操作。我在这里遗漏了什么吗?

您可以通过此获取以下数据

ID:$response->getId()

留言内容:$response->getMessage()

干杯