Comments (7)
Just wanted to post a note since the resolution on this issue seems to be pretty incomplete, and this ticket's page is the top google search result for "composer Clas 'Mailgun' not found". The actual problem causing this error appears to be that the sample code does not use the Mailgun namespace. See second line here, which I've updated to have the namespace:
require 'vendor/autoload.php';
$msg = new \Mailgun\Mailgun("key-xxxxxxxxxxxxxxxxxxxxxx");
$mg->sendMessage($domain, array('from' => '[email protected]',
'to' => '[email protected]',
'subject' => 'Sent from mailgun title',
'text' => 'Sent from mailgun message.'));
Without the namespace, the autoloader will not be triggered, and so you get the cited error. The example code appears to be incorrect in README.md and every other page I've seen.
If you carefully review the original issue as reported, zahidilead was clearly both already using composer and including the autoload.php file.
from mailgun-php.
You need to install mailgun library through composer. And you should use correct path for vendor/autolod in your script.
require 'path/to/file/vendor/autoload.php';
from mailgun-php.
Feel free to reach out to Mailgun support for help on this.
from mailgun-php.
Just so everyone is aware, I worked this for a few days before figuring it out. This was a good start.
The problem I had was that although my composer file had the Mailgun/Mailgun-php reference in it, I did NOT have the dependencies it needs. See this page for more details:
https://github.com/mailgun/mailgun-php
The three additional references I had to add to my composer.json file, plus Mailgun, are:
"Mailgun/Mailgun-php": "^1.0",
"php-http/curl-client": "^1.0",
"guzzlehttp/psr7": "^1.0",
"php-http/message": "^1.0",
Hope that helps people avoid the issues I did.
-j
from mailgun-php.
Hey @jetsetting-stressball.
Thank you for commenting on this issue. Though, it seams to be unrelated. (See dates for the original post).
About your issue and proposed solution: Did you read this section of the readme? https://github.com/mailgun/mailgun-php#why-requiring-so-many-packages
Have you seen the linked resource in that paragraph?
Composer must have given you a lot of error messages when you were trying to update. Or else you wouldn't get a "class not found".
from mailgun-php.
Yup, I read that part of the readme.
Nope, composer didn't give me any errors trying to update. That's why I was confused.
My original error was "Class 'Mailgun' not found", just like this post. Searching for answers I came across this post. It may not be perfectly related, but since I searched and found this page, I figured others may as well... and I'd hate for them to waste two days like I did.
My apologies if that's not the purpose of these communities, just trying to help!
from mailgun-php.
Nope, composer didn't give me any errors trying to update. That's why I was confused.
Interesting.
My apologies if that's not the purpose of these communities, just trying to help!
No need to apologize my friend. You've done nothing wrong. I too are trying to help you and anyone reading this thread after us. That's why I linked to resources, readme and told you about composer.
We should not steal this thread any more. Please open a new issue with your error message, composer file (before and after) and we'll make sure to find the cause of this issue.
from mailgun-php.
Related Issues (20)
- request for event microtime HOT 1
- Fatal error: Uncaught TypeError: Mailgun\Api\Domain::index() HOT 2
- Improvement: SDK version headers v2 vs v3 HOT 1
- Oudated symfony/http version HOT 3
- Bounces: The endpoint you have tried to access does not exist. HOT 2
- PHPDoc Type issue in Mailgun\Api\MailingList\Member HOT 2
- Get all lists
- TypeError: Mailgun\Api\Suppression\Bounce::show() HOT 1
- Bug: Proper json_last_error() handling with try catch
- Errors after latest update regarding json syntax HOT 2
- Error (4) when trying to json_decode response HOT 1
- Suppressions -> Bounces: cannot show for a specific address HOT 5
- Clarify effects of using php-http/discovery
- Returned data with send? HOT 1
- BCC not working properly when batch sending HOT 10
- Endpoint not correct for Tag > stats() HOT 1
- How to mock Mailgun?
- Get message from EU server?
- Feature Request: Add dkim_host_name and dkim_selector options to domains()->create() method HOT 2
- The template search filters do not match the documentation. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mailgun-php.