使用Mailgun php库的示例代码发送:HttpClientException

使用Mailgun php库的示例代码发送:HttpClientException,php,mailgun,Php,Mailgun,我有一个新的,激活的,付费的邮枪帐户和域名都是设置和验证。将其示例代码与我的密钥和域一起使用: $mg = Mailgun::create('key-XXXXX'); $mg->messages()->send('mailgun.MYDOMAIN.com', [ 'from' => 'bob@mailgun.MYDOMAIN.com', 'to' => 'sally@mailgun.MYDOMAIN.com', 'subject'

我有一个新的,激活的,付费的邮枪帐户和域名都是设置和验证。将其示例代码与我的密钥和域一起使用:

$mg = Mailgun::create('key-XXXXX');

$mg->messages()->send('mailgun.MYDOMAIN.com', [
    'from'    => 'bob@mailgun.MYDOMAIN.com',
    'to'      => 'sally@mailgun.MYDOMAIN.com',
    'subject' => 'The PHP SDK is awesome',
    'text'    => 'It is so simple to send a message'
]);
我得到了错误输出

Fatal error:  Uncaught exception 'Mailgun\Exception\HttpClientException' with message 'The parameters passed to the API were invalid. Check your inputs!' in /home/MYDOMAIN/public_html/include/vendor/mailgun/mailgun-php/src/Mailgun/Exception/HttpClientException.php:59
Stack trace:
#0 /home/MYDOMAIN/public_html/include/vendor/mailgun/mailgun-php/src/Mailgun/Api/HttpApi.php(91): Mailgun\Exception\HttpClientException::badRequest(Object(GuzzleHttp\Psr7\Response))
#1 /home/MYDOMAIN/public_html/include/vendor/mailgun/mailgun-php/src/Mailgun/Api/HttpApi.php(73): Mailgun\Api\HttpApi->handleErrors(Object(GuzzleHttp\Psr7\Response))
#2 /home/MYDOMAIN/public_html/include/vendor/mailgun/mailgun-php/src/Mailgun/Api/Message.php(52): Mailgun\Api\HttpApi->hydrateResponse(Object(GuzzleHttp\Psr7\Response), 'Mailgun\\Model\\M...')
#3 /home/MYDOMAIN/public_html/test.php(40): Mailgun\Api\Message->send('mailgun.MYDOMAIN...', Array)
#4 {main}
  thrown in /home/MYDOMAIN/public_html/include/vendor/mailgun/mailgun-php/src/Mailgun/Exception/HttpClientException.php on line 59
响应对象的
var\u dump()
为我提供了。。。不多:

object(GuzzleHttp\Psr7\Response)#32 (6) {
  ["reasonPhrase":"GuzzleHttp\Psr7\Response":private]=>
  string(11) "BAD REQUEST"
  ["statusCode":"GuzzleHttp\Psr7\Response":private]=>
  int(400)
  ["headers":"GuzzleHttp\Psr7\Response":private]=>
  array(5) {
    ["Content-Type"]=>
    array(1) {
      [0]=>
      string(16) "application/json"
    }
    ["Date"]=>
    array(1) {
      [0]=>
      string(29) "Sat, 16 Dec 2017 21:06:26 GMT"
    }
    ["Server"]=>
    array(1) {
      [0]=>
      string(5) "nginx"
    }
    ["Content-Length"]=>
    array(1) {
      [0]=>
      string(3) "137"
    }
    ["Connection"]=>
    array(1) {
      [0]=>
      string(10) "keep-alive"
    }
  }
  ["headerNames":"GuzzleHttp\Psr7\Response":private]=>
  array(5) {
    ["content-type"]=>
    string(12) "Content-Type"
    ["date"]=>
    string(4) "Date"
    ["server"]=>
    string(6) "Server"
    ["content-length"]=>
    string(14) "Content-Length"
    ["connection"]=>
    string(10) "Connection"
  }
  ["protocol":"GuzzleHttp\Psr7\Response":private]=>
  string(3) "1.1"
  ["stream":"GuzzleHttp\Psr7\Response":private]=>
  object(GuzzleHttp\Psr7\Stream)#31 (7) {
    ["stream":"GuzzleHttp\Psr7\Stream":private]=>
    resource(83) of type (stream)
    ["size":"GuzzleHttp\Psr7\Stream":private]=>
    NULL
    ["seekable":"GuzzleHttp\Psr7\Stream":private]=>
    bool(true)
    ["readable":"GuzzleHttp\Psr7\Stream":private]=>
    bool(true)
    ["writable":"GuzzleHttp\Psr7\Stream":private]=>
    bool(true)
    ["uri":"GuzzleHttp\Psr7\Stream":private]=>
    string(10) "php://temp"
    ["customMetadata":"GuzzleHttp\Psr7\Stream":private]=>
    array(0) {
    }
  }
}
我尝试使用他们发布在github上的调试解决方案:

$configurator = new Mailgun\HttpClientConfigurator();
$configurator->setEndpoint('http://bin.mailgun.net/f1e56c6a');
$configurator->setDebug(true);
$mg = Mailgun\Mailgun::configure($configurator);

# Now, compose and send your message.
$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.'
]);
这只为我提供了另一个无用的错误响应:

Fatal error:  Uncaught exception 'Mailgun\Exception\HydrationException' with message 'The ModelHydrator cannot hydrate response with Content-Type: text/html;charset=utf-8' in /home/MYDOMAIN/public_html/include/vendor/mailgun/mailgun-php/src/Mailgun/Hydrator/ModelHydrator.php:34

我使用的是PHPV5.6.32。我无法收集任何信息来解决此错误。有没有人有过这方面的经验或想法?

Mailgun有一条糟糕的错误消息。支持人员已联系我,并表示传递给API的参数无效。检查您的输入意味着,虽然我已经验证了我的电子邮件,验证了我的域名,验证了我的信用卡,但我还没有将手机号码链接到我的帐户