API Mailgun Send gives me an error

Being trying to use Mailgun on a tutorial.
I get this error and I am stuck…

This is on my localhost apache windows

Fatal error

Uncaught exception: ‘Http\Discovery\Exception\NotFoundException’

Message: ‘No PSR-17 url factory found. Install a package from this list: https://packagist.org/providers/psr/http-factory-implementation

Call to Mail Class
Mail::send('xxxx@gmail.com','Test','This is a test', '<h1>This is a test</h1>');

Mail Class

<?php

namespace App;

use App\Config;
use Mailgun\Mailgun;

/**
 * Mail
 *
 * PHP version 7.0
 */
class Mail
{

    /**
     * Send a message
     *
     * @param string $to Recipient
     * @param string $subject Subject
     * @param string $text Text-only content of the message
     * @param string $html HTML content of the message
     *
     * @return mixed
     */
    public static function send($to, $subject, $text, $html)
    {
        $domain = "https://app.mailgun.com/app/sending/domains/sandboxa38feaf00c804083b97e97be976b62d5.mailgun.org";

        # First, instantiate the SDK with your API credentials
        $mg = Mailgun::create('XXX');

        # Now, compose and send your message.
        # $mg->messages()->send($domain, $params);
        $mg->messages()->send($domain, [
            'from'    => 'Excited User <mailgun@$domain>',
            'to'      => $to,
            'subject' => $subject,
            'text'    => $text
        ]);
    }


}

Solved
Running this on composer helped.

composer require mailgun/mailgun-php kriswallsmith/buzz nyholm/psr7
1 Like

Glad you resolved this and thanks for posting the solution in case someone has the same issue in the future.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.