【发布时间】:2020-05-26 12:31:15
【问题描述】:
我第一次使用 Mailgun 向用户发送邮件。
我正在使用下面的邮件进行测试
<?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' => 'sender@mydomain.com', // this is registered email address
'to' => 'receiver@gmail.com',
'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"
}
}
现在,当我运行我的页面时,我遇到了错误。我在 GoDaddy 上添加了我的域、TXT、MX。
致命错误:未捕获 Http\Discovery\Exception\DiscoveryFailedException: 找不到 使用任何发现策略的资源。在以下位置查找更多信息 http://docs.php-http.org/en/latest/discovery.html#common-errors - 埔里 工厂不可用 - 使用策略未找到有效候选人 “Http\Discovery\Strategy\CommonClassesStrategy”。我们测试了 以下候选人: 。 - 使用策略未找到有效候选人 “Http\Discovery\Strategy\CommonPsr17ClassesStrategy”。我们测试了 以下候选人:Nyholm\Psr7\Factory\Psr17Factory, Zend\Diactoros\UriFactory, Http\Factory\Diactoros\UriFactory, Http\Factory\Guzzle\UriFactory,Http\Factory\Slim\UriFactory。在 /opt/lampp/htdocs/mailgun-php/vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php:41 堆栈跟踪:#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): 在 /opt/lampp/htdocs/mailgun-php/vendor/php-http/discovery/src/Psr17FactoryDiscovery.php 在第 22 行
你能帮我解决这个问题吗?
【问题讨论】:
-
嘿,你能在哪里解决它?我有完全相同的问题
-
@bermick,不,我也想知道答案。
-
你的版本是什么?我正在使用 laravel 5、php 7 和 mailgun 3
-
@bermick,我正在使用 php7 和 mailgun 最新的一个。
-
@bermick,是的,SendGrid 很好。我还建议你使用那个 instated 的 mailgun