icodestuff/laravel-mailwind
最新稳定版本:2.1.0
Composer 安装命令:
composer require icodestuff/laravel-mailwind
包简介
Compile TailwindCSS to a Laravel mailable
关键字:
README 文档
README
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:
composer require icodestuff/laravel-mailwind
You need to publish the views with:
php artisan vendor:publish --tag="mailwind-views"
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:
php artisan mailwind:create MyTemplate
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:
php artisan mailwind:generate
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:
php artisan make:mail YourMailable
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
Mail::to('test@example.com')->send(new App\Mail\YourMailable())
to send out your email. If you are using Mailhog, you can visit http://localhost:8025/ to see the email:

Testing
composer test
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.
统计信息
- 总下载量: 56
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-10-06
