Support the ongoing development of →
IOC Views Mail
Last updated 2 years ago.

What an active community!

Last updated 2 years ago.

Hi ammont.

I was recently looking into the same thing. Check out this package:

It will create a plugin for swiftmail (the underlining library for Laravel's mail component) that will inline your CSS.

It does make sending mail (even) slower, so you might want to consider using Laravel's queue feature.

Hope that's what you're looking for.


Last updated 2 years ago.

The laravel inliner linked above didn't work as expected. It has huge issues working with multiple CSS rules for the same elements and media queries. Premailer works much better for me. I found a PHP lib which executes Ruby code (Premailer is ruby gem).

I created a simple laravel wrapper for it, you can get it here:

Inliner::argument('include_style_tags', true);
Inliner::argument('preserve_styles', true);
$body = Inliner::getConvertedHtml();

Mail::send('data', array('data' => $body), function($message)
	$message->to('[email protected]', 'John Smith')->subject('Welcome!');

Note: data.blade.php is just a dummy view with the following code (is there a better way to do this?)

{{ $data }}
Last updated 2 years ago.


@emilsundberg, I'm trying to use your inliner library, but I have some questions,

When I call a method, e.g. Inliner::view, I get the error

Call to undefined method Emil\Inliner\Inliner::view()

I added Inliner as a service provider in my config/app.php, but should I have to add it as a class alias in that file?

If my template has dynamic data, could I call the method as

$data = array('name' => $user->name, 'language' => 'en');		
Inliner::view('emails.welcome', $data);

to fill my custom variables in the template?

Thank you in advance! ;)

Last updated 2 years ago.

Sign in to participate in this thread!


Your banner here too?

ammont ammont Joined 10 Feb 2014


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.