Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The endpoint you've tried to access does not exist #71

Closed
ezyone123 opened this issue Jan 13, 2015 · 7 comments
Closed

The endpoint you've tried to access does not exist #71

ezyone123 opened this issue Jan 13, 2015 · 7 comments

Comments

@ezyone123
Copy link

I am getting this error when trying to send a simple email. I have double checked my domain as that was the solution for the few other people who had the same issue, I'm sure its the same one I used to set up my malign account.

  <br />
  <b>Notice</b>:  Array to string conversion in <b>/var/www/html/php_libs/vendor/mailgun/mailgun-     php/src/Mailgun/Mailgun.php</b> on line <b>36</b><br />
 <br />
 <b>Fatal error</b>:  Uncaught exception 'Mailgun\Connection\Exceptions\MissingEndpoint' with message 'The endpoint you've tried to access does not exist. Check your URL.' in /var/www/html/php_libs/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php:133
 Stack trace:
 #0 /var/www/html/php_libs/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php(90): Mailgun\Connection\RestClient-&gt;responseHandler(Object(Guzzle\Http\Message\Response))
 #1 /var/www/html/php_libs/vendor/mailgun/mailgun-php/src/Mailgun/Mailgun.php(80): Mailgun\Connection\RestClient-&gt;post('Array/messages', Array, Array)
 #2 /var/www/html/php_libs/vendor/mailgun/mailgun-php/src/Mailgun/Mailgun.php(36): Mailgun\Mailgun-&gt;post('Array/messages', Array, Array)
 #3 /var/www/html/api/newuser.php(136): Mailgun\Mailgun-&gt;sendMessage(Array, Array)
 #4 {main}
 thrown in <b>/var/www/html/php_libs/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php</b> on line <b>133</b><br />

my code:

 require '/var/www/html/php_libs/vendor/autoload.php';
 use Mailgun\Mailgun;
 $mg = new Mailgun("key-3f2814XXXXXXX");
 $domain = 'stnatoday.com';
 $mg->sendMessage($domain, array('from'    => 'me@stnatoday.com', 
                            'to'      => trim($_REQUEST['identifier']), 
                            'subject' => 'The PHP SDK is awesome!', 
                            'text'    => 'It is so simple to send a message.'));
@CupOfTea696
Copy link
Contributor

Go to the RestClient.php file and edit it where the error originated:

        elseif($httpResponseCode == 400){
            die(var_dump((string) $responseObj->getBody()));
            throw new MissingRequiredParameters(EXCEPTION_MISSING_REQUIRED_PARAMETERS);
        }
        elseif($httpResponseCode == 401){
            die(var_dump((string) $responseObj->getBody()));
            throw new InvalidCredentials(EXCEPTION_INVALID_CREDENTIALS);
        }
        elseif($httpResponseCode == 404){
            die(var_dump((string) $responseObj->getBody()));
            throw new MissingEndpoint(EXCEPTION_MISSING_ENDPOINT);
        }

This way you can actually see the response from the request to Mailgun. It might help you figure out what went wrong.
Mailgun should update their package to show this info in the error. I'm gonna make this a bit better looking and create a pull request.

@ezyone123
Copy link
Author

Turns out I had not verified my account. Got it figured out, thanks!

@CupOfTea696
Copy link
Contributor

You're welcome!

@mnpenner
Copy link

Looks like the error messages were never updated. I just downloaded the SDK and got this cryptic message today. I thought I had to supply the 2nd arg to the c'tor, but that led to a whole new set of problems.

jessespears pushed a commit that referenced this issue May 5, 2015
Fix for #71: Show response message on 400, 401 and 404.
@andrebruton
Copy link

Is it not possible for the PHP library code to return an error instead of a fatal error. I do not want fatal errors in a production environment.

I check for returned code and if 200 then i know the email has been delivered to Mailgun.

@mnpenner
Copy link

@andrebruton You can always put a try {} catch {} around it.

This error message should still be updated to say "This domain has not been verified yet" or something, if that is indeed the problem.

@andrebruton
Copy link

Thank you. Tried it and I get a message back. Does this look good?

` try {
# Now, compose and send your message.
$result=$mg->sendMessage($domain, array('from' => 'info@mg.domain.co.za',
'to' => 'user@email.com',
'subject' => $subject,
'text' => $message,
'html' => $message_html
));

if ($result->http_response_code == 200) {

  echo "Email Successfully Sent<br>";

  echo "<pre>";
  print_r($result);
  echo "</pre>";

  echo "Result: " . $result->http_response_code . "<p>";

} else {
   echo "Error sending email<br>";
}

} catch(Exception $e) {
  // Mandrill errors are thrown as exceptions
  echo "Error occured: " . $e->getMessage() . "<br>";
}

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants