Reputation: 2307
I am using Mailgun first time for sending the mail to the user.
I am using below mail for testing
<?php
require 'vendor/autoload.php';
use Mailgun\Mailgun;
# Instantiate the client.
$mgClient = Mailgun::create('api key', 'https://API_HOSTNAME');
$domain = "mydomain.com";
$params = array(
'from' => '[email protected]', // this is registered email address
'to' => '[email protected]',
'subject' => 'Hello',
'text' => 'Testing some Mailgun awesomness!'
);
# Make the call to the client.
$mg->messages()->send($domain, $params);
?>
Composer.json
{
"require": {
"mailgun/mailgun-php": "^3.0",
"php-http/guzzle6-adapter": "^2.0",
"php-http/message": "^1.8"
}
}
Now when I run my page then I am getting below error. I added my domain, TXT, MX on GoDaddy.
Fatal error: Uncaught Http\Discovery\Exception\DiscoveryFailedException: Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors - Puli Factory is not available - No valid candidate found using strategy "Http\Discovery\Strategy\CommonClassesStrategy". We tested the following candidates: . - No valid candidate found using strategy "Http\Discovery\Strategy\CommonPsr17ClassesStrategy". We tested the following candidates: Nyholm\Psr7\Factory\Psr17Factory, Zend\Diactoros\UriFactory, Http\Factory\Diactoros\UriFactory, Http\Factory\Guzzle\UriFactory, Http\Factory\Slim\UriFactory. in /opt/lampp/htdocs/mailgun-php/vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php:41 Stack trace: #0 /opt/lampp/htdocs/mailgun-php/vendor/php-http/discovery/src/ClassDiscovery.php(79): Http\Discovery\Exception\DiscoveryFailedException::create(Array) #1 /opt/lampp/htdocs/mailgun-php/vendor/php-http/discovery/src/Psr17FactoryDiscovery.php(117): in /opt/lampp/htdocs/mailgun-php/vendor/php-http/discovery/src/Psr17FactoryDiscovery.php on line 22
Would you help me out with this issue?
Upvotes: 1
Views: 2557
Reputation: 557
from mailgun's github repo, https://github.com/mailgun/mailgun-php#installation
If you just want to get started quickly you should run the following command:
composer require mailgun/mailgun-php kriswallsmith/buzz nyholm/psr7
run the above composer instruction and the error should be gone
i had the same issue, and that solved it for me, that is provided your are doing everything else right(apikey, hostname and domain)
if you still get stuck, then just follow the remaining instruction in the GitHub repo
Upvotes: 2