TheDoctor0 / laravel-mailjet-driver

Laravel mail driver package for Mailjet and wrapper for its API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Package not compatible with Laravel 9

mdelariva opened this issue · comments

Since I have upgraded to Laravel 9, this packaged stoped working. I was able to upgrade to 1.0.4 but I get an error trying to send emails:
Illuminate\Mail\Mailer::__construct(): Argument #3 ($transport) must be of type Symfony\Component\Mailer\Transport\TransportInterface, Mailjet\LaravelMailjet\Transport\MailjetTransport given, called in /var/www/my-project/src/vendor/laravel/framework/src/Illuminate/Mail/MailManager.php on line 120 {"exception":"[object] (TypeError(code: 0): Illuminate\\Mail\\Mailer::__construct(): Argument #3 ($transport) must be of type Symfony\\Component\\Mailer\\Transport\\TransportInterface, Mailjet\\LaravelMailjet\\Transport\\MailjetTransport given, called in /var/www/my-project/src/vendor/laravel/framework/src/Illuminate/Mail/MailManager.php on line 120 at /var/www/my-project/src/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php:98)

I believe this error is related with Laravel 9 new mail driver migration from Swift to Symfony (https://laravel.com/docs/9.x/upgrade#symfony-mailer), but I am not sure.

Could you help me with this? Thanks,

Hey @mdelariva.
It looks like Laravel 9 requires Symfony 6 mailer. I just pushed a commit that should solve this issue.
Before tagging a release, can you test if you can install the package directly from the GitHub repo with this fix?

Add this to your composer.json:

"repositories": [
    {
        "url": "https://github.com/TheDoctor0/laravel-mailjet-driver.git",
        "type": "git"
    }
],

Then you should be able to install it like so:

composer require thedoctor0/laravel-mailjet-driver dev-master

Hey @TheDoctor0 ! Thanks for quick response and update.
I've tried the changes you made and now I get a new error:
You cannot use "Symfony\Component\Mailer\Transport\AbstractHttpTransport" as the HttpClient component is not installed. Try running "composer require symfony/http-client". {"exception":"[object] (LogicException(code: 0): You cannot use \"Symfony\\Component\\Mailer\\Transport\\AbstractHttpTransport\" as the HttpClient component is not installed. Try running \"composer require symfony/http-client\". at /var/www/html/vendor/symfony/mailer/Transport/AbstractHttpTransport.php:36) [stacktrace] #0 /var/www/html/vendor/symfony/mailjet-mailer/Transport/MailjetApiTransport.php(62): Symfony\\Component\\Mailer\\Transport\\AbstractHttpTransport->__construct(NULL, NULL, NULL) #1 /var/www/html/vendor/symfony/mailjet-mailer/Transport/MailjetTransportFactory.php(29): Symfony\\Component\\Mailer\\Bridge\\Mailjet\\Transport\\MailjetApiTransport->__construct('ab51b836c182ec8...', '54e47d68759b0ef...', NULL, NULL, NULL) #2 /var/www/html/vendor/thedoctor0/laravel-mailjet-driver/src/MailjetServiceProvider.php(28): Symfony\\Component\\Mailer\\Bridge\\Mailjet\\Transport\\MailjetTransportFactory->create(Object(Symfony\\Component\\Mailer\\Transport\\Dsn)) #3 [internal function]: Mailjet\\LaravelMailjet\\MailjetServiceProvider->Mailjet\\LaravelMailjet\\{closure}(Array) #4 /var/www/html/vendor/laravel/framework/src/Illuminate/Mail/MailManager.php(153): call_user_func(Object(Closure), Array) #5 /var/www/html/vendor/laravel/framework/src/Illuminate/Mail/MailManager.php(119): Illuminate\\Mail\\MailManager->createSymfonyTransport(Array) #6 /var/www/html/vendor/laravel/framework/src/Illuminate/Mail/MailManager.php(94): Illuminate\\Mail\\MailManager->resolve('mailjet') #7 /var/www/html/vendor/laravel/framework/src/Illuminate/Mail/MailManager.php(72): Illuminate\\Mail\\MailManager->get('mailjet') #8 /var/www/html/vendor/laravel/framework/src/Illuminate/Mail/MailManager.php(505): Illuminate\\Mail\\MailManager->mailer()

In case anyone else wants to try this, just make sure to use vcs as repository type, instead of git.

Thanks!

@mdelariva, you mentioned the upgrade guide for Laravel 9 and it clearly states that symfony/http-client should be installed when using a Symfony mailer. So first execute:

composer require symfony/http-client

and after that:

composer require thedoctor0/laravel-mailjet-driver dev-master

@TheDoctor0 you are correct, I miss that package requirement. I have installed it and it worked.
Thanks!

I just tagged a new release (2.0), so @mdelariva if you want you can install it now without defining a repository in composer.json.