Skip to content

Mandrill-driver together with css-inliner #84

@juukie

Description

@juukie

Hi! First of all thanks for creating and maintaining this package :-).

I've installed it together with therobfonz/laravel-mandrill-driver. Both packages use Laravel's auto-discovery feature.

The css-inliner package boots before the mandrill-driver package, but since the css-inliner needs the SwiftMailer it tries to build the mail (Mandrill) transport which is not registered in the mail manager yet.

Schermafbeelding 2020-04-30 om 16 04 21

$this->app->extend('mail.manager', function (MailManager $mailManager) {
    $mailManager->getSwiftMailer()->registerPlugin($this->app->make(CssInlinerPlugin::class));
    return $mailManager;
});

To make both packages work I tried to add them to composer.json's dont-discover array:

"dont-discover": [
    "fedeisas/laravel-mail-css-inliner",
    "therobfonz/laravel-mandrill-driver" 
]

and register their service providers manually via config/app.php:

/** Package Service Providers... */
\LaravelMandrill\MandrillServiceProvider::class,
\Fedeisas\LaravelMailCssInliner\LaravelMailCssInlinerServiceProvider::class,

but it did not solve the problem straight away. Only when I moved

$this->app->extend('mail.manager', function (MailManager $mailManager) {
    $mailManager->getSwiftMailer()->registerPlugin($this->app->make(CssInlinerPlugin::class));
    return $mailManager;
});

into LaravelMailCssInlinerServiceProvider::boot().

Since I shouldn't change the files in /vendor, I've added

$this->app->register(\Fedeisas\LaravelMailCssInliner\LaravelMailCssInlinerServiceProvider::class);

to AppServiceProvider::boot().
So the LaravelMailCssInlinerServiceProvider will be registered after the laravel-mandrill-driver.

Both packages used to work together in Laravel 6. Laravel 7's changes on the mailing system seems to be the problem. Not sure if the solution to this issue would be to just move the extending of the mail.manager into boot() since therobfonz/laravel-mandrill-driver is auto-discovered after fedeisas/laravel-mail-css-inliner.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions