Bogardo / Mailgun

Mailgun package for Laravel
MIT License
295 stars 114 forks source link

Trying to get property of non-object #146

Open dk-jessn opened 6 years ago

dk-jessn commented 6 years ago

[2018-09-05 12:57:24] local.ERROR: exception 'ErrorException' with message 'Trying to get property of non-object' in /vagrant/api/vendor/bogardo/mailgun/src/Http/Response.php:37

public function __construct(stdClass $response)
{
    $this->status = $response->http_response_code;
    $this->message = $response->http_response_body->message;  // Line 37
    $this->id = property_exists($response->http_response_body, 'id') ? $response->http_response_body->id : '';
    $this->data = null;
}

It looks like that no body is returned, and it is not handled in the ctor properly?

martsie commented 6 years ago

I faced the same issue.

There's an error in the documentation for this module because it says to publish the config but also to edit .env file and use either. The problem is if you publish the config it'll use that instead of the .env variables you set.

Try setting the variables in your mailgun.php file and make sure the domain is correct and see if that helps.