Skip to content
This repository has been archived by the owner on Dec 22, 2019. It is now read-only.

Troubles with the API request, deprecated usable of mailgun-php lib #144

Open
csimpi opened this issue Jul 8, 2018 · 2 comments
Open

Troubles with the API request, deprecated usable of mailgun-php lib #144

csimpi opened this issue Jul 8, 2018 · 2 comments

Comments

@csimpi
Copy link

csimpi commented Jul 8, 2018

It seems this project has been abandoned and doesn't really works with the new version of mailgun api.
I'm not sure about this, but I couldn't make it work, I'm getting Mailgun Magnificent API response after any API request that this wrapper sends through Mailgun API.

I modified the package on my local and added some debugging, the configuration seems to be okay.

When I opened the https://github.com/Bogardo/Mailgun/blob/master/src/Mail/Mailer.php file I realized, this wrapper uses deprecated methods, so I suppose this causes the
Trying to get property of non-object" on line 37 of .../vendor/bogardo/mailgun/src/Http/Response.php error, since the wrong request generates a reponse that not has message property.

Everybody who would like to use the mailgun-php (https://github.com/mailgun/mailgun-php) client with Laravel project can implement and use the original package with adding this line to the /config/app.php file to the aliases array:
'Mailgun' => Mailgun\Mailgun::class,

then you will be able to use original mailgun-php client's functions, like:

        $mg = Mailgun::create(env('MAILGUN_PRIVATE'));
        $dns = $mg->domains()->show(env('MAILGUN_DOMAIN'))->getInboundDNSRecords();
        dump($dns);

I removed bogardo/mailgun wrapper
composer remove bogardo/mailgun
Installed mailgun and guzzle adapter
composer require mailgun/mailgun-php
composer require php-http/guzzle6-adapter

@azwel
Copy link

azwel commented Jul 9, 2018

@csimpi this project does work.
The response Trying to get property of non-object" on line 37 of .../vendor/bogardo/mailgun/src/Http/Response.php is caused by invalid config settings from config/mailgun.php file which by default seems not to utilize the .env settings.
Quick fix:

    /*
     * Domain name registered with Mailgun
     *
     */
    'domain' => env('MAILGUN_DOMAIN'),

    /*
     * Mailgun (private) API key
     *
     */
    'api_key' => env('MAILGUN_PRIVATE'),

    /*
     * Mailgun public API key
     *
     */
    'public_api_key' => env('MAILGUN_PUBLIC'),

and everything works fine!

Edit:

That's strange... the config in the repository does contain reading from .env however the one that published using publish command doesn't!

@csimpi
Copy link
Author

csimpi commented Jul 9, 2018

Great news! Thank you for the clarification.
I added the details to the env file only as the documentation says. I supposed those vars are coming directly from the env file, not through the mailgun config file.

I think you should change the documentation about the default/published config file difference, there are a couple of similar tickets regarding this issue, without any answer.

Finally, I'm going to use the raw mailgun-php package in Laravel since that's easier to use with the mailgun official documentation, but I wanna say thank you for your work and the solution also.

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

No branches or pull requests

2 participants