mailgun / mailgun-php

Mailgun's Official SDK for PHP
http://www.mailgun.com
MIT License
1.09k stars 314 forks source link

Suppressions -> Bounces: cannot show for a specific address #887

Closed mikegreen closed 8 months ago

mikegreen commented 8 months ago

I'm trying to check if a suppression exists before adding it.

The docs here: https://github.com/mailgun/mailgun-php/blob/master/doc/index.md#suppression-api, show this for "Show bounces for a specific address"

$mailgun->suppressions()->bounces()->show('example.com', 'alice@gmail.com');

When I try that, specifically with $responseSupression = $mailgun->suppressions()->bounces()->show('domain.com', 'bob@email.com');

It fails with:

PHP Fatal error:  Uncaught Mailgun\Exception\HttpClientException: The endpoint you have tried to access does not exist. Check if the domain matches the domain you have configure on Mailgun.
Stack trace:
#0 /Users/x/Documents/GitHub/mailgun-failures/vendor/mailgun/mailgun-php/src/Api/HttpApi.php(100): Mailgun\Exception\HttpClientException::notFound(Object(Nyholm\Psr7\Response))
#1 /Users/x/Documents/GitHub/mailgun-failures/vendor/mailgun/mailgun-php/src/Api/HttpApi.php(76): Mailgun\Api\HttpApi->handleErrors(Object(Nyholm\Psr7\Response))
#2 /Users/x/Documents/GitHub/mailgun-failures/vendor/mailgun/mailgun-php/src/Api/Suppression/Bounce.php(64): Mailgun\Api\HttpApi->hydrateResponse(Object(Nyholm\Psr7\Response), 'Mailgun\\Model\\S...')
#3 /Users/x/Documents/GitHub/mailgun-failures/check-failures.php(18): Mailgun\Api\Suppression\Bounce->show('domain.com', 'bob@email.com')
#4 {main}
  thrown in /Users/michaelgreen/Documents/GitHub/mailgun-failures/vendor/mailgun/mailgun-php/src/Exception/HttpClientException.php on line 78

This domain matches, and it works with other endpoints (see bottom). Using an API key for my user who is an account admin.

I can get the entire list, via $responseBounces = $mailgun->suppressions()->bounces()->index($sendingDomain);

Is this not implemented? Is this error hiding somethign else?

oleksandr-mykhailenko commented 8 months ago

Hello @mikegreen Unfortunately, I do not have a quick answer for you right now but I can say that we will take a look during next day and I will be back with answer soon

oleksandr-mykhailenko commented 8 months ago

Hello @mikegreen So I tested code. In my case everuthing works good.

I have a results

Mailgun\Model\Suppression\Bounce\ShowResponse Object
(
    [address:Mailgun\Model\Suppression\Bounce\Bounce:private] => test@gmail.com
    [code:Mailgun\Model\Suppression\Bounce\Bounce:private] => 550
    [error:Mailgun\Model\Suppression\Bounce\Bounce:private] => aaaaaa
    [createdAt:Mailgun\Model\Suppression\Bounce\Bounce:private] => DateTimeImmutable Object
        (
            [date] => 2023-11-27 10:10:19.000000
            [timezone_type] => 3
            [timezone] => UTC
        )

)

image

Please, check your configuration of domain and key (probably domain is wrong)

mikegreen commented 8 months ago

hi @oleksandr-mykhailenko - thanks for that.

Just got back to this project and it ran fine today.. I wonder if the API keys are eventually consistent or such? Same code, same domain variable. 🤷🏼 It was a new API key...

thanks for circling back!

mikegreen commented 8 months ago

Hey @oleksandr-mykhailenko can you try it with a non-existant bounce email address? I realized it does work for a valid bounce, but if its not found - it gives the The endpoint you have tried to access does not exist. which I don't think is expected.

oleksandr-mykhailenko commented 8 months ago

Hello @mikegreen So we fixed that in new version. Right now it shows message from the server in case of 404 error