2017-12-16 1 views
-1

Ich habe ein neues, aktiviert, bezahlt Mailgun-Konto und die Domänen sind alle eingerichtet und verifiziert. Mit ihren Beispielcode mit meinem Schlüssel und Domain:Senden mit Mailgun: HttpClientException mit Beispielcode mit mailgun-php Bibliothek

$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' 
]); 

bekomme ich die Fehlerausgabe

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 

A var_dump() der Antwort Objekt gibt mir ... nicht viel:

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) { 
    } 
    } 
} 

Ich habe versucht, mit ihrer Debug-Lösung auf dem Github geschrieben:

$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.' 
]); 

, die mir nur eine weitere nutzlose Fehlerreaktion zur Verfügung gestellt:

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 

ich PHP v5.6.32 bin mit. Es gibt keine Informationen, die ich herausfinden kann, um diesen Fehler zu beheben. Jeder hat Erfahrung mit diesem oder irgendwelchen Ideen?

Antwort

0

Mailgun hat eine beschissene Fehlermeldung. Support hat mich kontaktiert und sagte 'The parameters passed to the API were invalid. Check your inputs!' bedeutet, dass, während ich meine E-Mail verifiziert, meine Domain verifiziert und meine Kreditkarte verifiziert habe, habe ich noch keine Handynummer mit meinem Konto verknüpft.