Thasmo's avatar

How to inject the Mailer class?

I've added "illuminate/mail": "~5.0" to my composer.json, installed it and also registered the service provider via $app->register('Illuminate\Mail\MailServiceProvider');.

Within a self-handling Job I try to inject the Mailer object but I get this error:

BindingResolutionException in Container.php line 788:
Target [Swift_Transport] is not instantiable.

Is there anything else I need to configure to use the Mailer class directly without using it's Facade?

0 likes
3 replies
bestmomo's avatar
Level 52

You only need this :

use Illuminate\Contracts\Mail\Mailer
Thasmo's avatar

Ah, so true - thanks for your replies!

Please or to participate in this conversation.