我有一个新的,激活的,付费的mailgun帐户,域名都已设置和验证。将他们的示例代码与我的密钥和域一起使用:
$mg = Mailgun::create('key-XXXXX');
$mg->messages()->send('mailgun.MYDOMAIN.com', [
'from' => '[email protected]',
'to' => '[email protected]',
'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_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' => '[email protected]',
'to' => '[email protected]',
'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
我正在使用PHP v5.6.32。我无法收集任何信息来解决此错误。任何人都有这方面或任何想法的经验?
Mailgun有一个糟糕的错误消息。支持已联系我,并说'The parameters passed to the API were invalid. Check your inputs!'
意味着,虽然我已验证了我的电子邮件,验证了我的域名,并验证了我的信用卡,但我还没有将手机号码链接到我的帐户。