致命错误:使用mailgun发送邮件时,未捕获的异常'RuntimeException',消息'Puli Factory不可用'

Nik*_*iya 5 php guzzle mailgun

我正在尝试使用以下代码发送邮件,我正在使用guzzlehttp,但是收到Fatal error: Uncaught exception 'RuntimeException'消息'Puli Factory is not available'.请帮我找一个解决方案,谢谢!

这是我的代码:

require 'vendor/autoload.php';
use Mailgun\Mailgun;

# Instantiate the client.
$mgClient = new Mailgun('key-');
$domain = "domain";

# Make the call to the client.
$result = $mgClient->sendMessage("$domain",
              array('from'    => 'Mailgun Sandbox      <xxxxxx@sandbox.mailgun.org>',
                    'to'      => 'John Doe<xxxxx@abc.com>',
                    'subject' => 'Hello John Doe',
                    'text'    => 'Email Text'));
Run Code Online (Sandbox Code Playgroud)

并且我用原始文件替换了密钥和域名.

dor*_*ndo 7

我有同样的问题.

尝试:

$client = new \Http\Adapter\Guzzle6\Client(); 
$mailgun = new \Mailgun\Mailgun('api_key', $client);
Run Code Online (Sandbox Code Playgroud)

然后:

$mailgun->sendMessage(.....)
Run Code Online (Sandbox Code Playgroud)

希望它对你有所帮助.

  • 你需要拉6口才能工作.(php composer.phar需要php-http/guzzle6-adapter:^ 1.0) (3认同)