Download the PHP package icodestuff/laravel-mailwind without Composer
On this page you can find all versions of the php package icodestuff/laravel-mailwind. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download icodestuff/laravel-mailwind
More information about icodestuff/laravel-mailwind
Files in icodestuff/laravel-mailwind
Package laravel-mailwind
Short Description Compile TailwindCSS to a Laravel mailable
License MIT
Homepage https://github.com/icodestuff-io/laravel-mailwind
Informations about the package laravel-mailwind
About Laravel Mailwind
Use TailwindCSS to design your Laravel Mailables instead of relying on markdown or inline styles. NOTE after testing this package on multiple email clients, I am sad to announce it'll likely never be production ready 😢
Requires
- Laravel 9
- TailwindCSS
Installation
You can install the package via composer:
You need to publish the views with:
Getting Started
Create a template
By default, Mailwind exports an example template called: mailwind-example-template.blade.php
.
If you want to create a new template, you can run:
which will generate the file my-template.blade.php
within resources/views/vendor/mailwind/templates
.
In order to use Mailwind, you MUST add new templates to the
resources/views/vendor/mailwind/templates
. Note, we don't currently support subdirectories within thetemplates/
folder.
Generate mail views
By default, Mailwind picks up on changes to your email template but if you want to regenerate all of your views, you can run the generate command:
which will generate compiled views within the resources/views/vendor/mailwind/generated
directory. Note,
all generated files are ignored by git, so it is recommended to run the php artisan mailwind:generate
in your deployment scripts similar to
npm run prod
.
Prepare your Mailable
Generate a new Laravel mailable by running:
Then associate Mailwind with a mailable by implementing the trait InteractsWithMailWind
like so:
namespace App\Mail;
use Icodestuff\Mailwind\Traits\InteractsWithMailWind;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class YourMailable extends Mailable
{
use Queueable, SerializesModels, InteractsWithMailWind;
}
Then within the build method, use the template that we created within the resources/views/vendor/mailwind/templates
directory
like so:
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->view('mailwind::templates.my-template') // maps to: resources/views/vendor/mailwind/templates/my-template.blade.php
->subject('Mailwind Example Email');
}
Send the Mailable
Run php artisan tinker
then paste
to send out your email. If you are using Mailhog, you can visit http://localhost:8025/ to see the email:
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-mailwind with dependencies
illuminate/contracts Version ^9.0
spatie/laravel-package-tools Version ^1.13.0
tijsverkoyen/css-to-inline-styles Version ^2.2