fedeisas/laravel-mail-css-inliner
Composer 安装命令:
composer require fedeisas/laravel-mail-css-inliner
包简介
Inline the CSS of your HTML emails using Laravel
README 文档
README
Why?
Most email clients won't render CSS (on a <link> or a <style>). The solution is inline your CSS directly on the HTML. Doing this by hand easily turns into unmantainable templates.
The goal of this package is to automate the process of inlining that CSS before sending the emails.
Installation and compatibility
Starting with version 5 this package requires PHP 8.0 and Laravel 9.0 or higher.
Using an older version of PHP / Laravel?
If you are on a PHP version below 8.0 or a Laravel version below 9.0 just use version 4.* of this package.
How?
Using a wonderful CSS inliner package wrapped in a Symfony Mailer plugin and served as a Service Provider it just works without any configuration. Since this is a Symfony Mailer plugin, it will automatically inline your css when parsing an email template. You don't have to do anything!
Turns style tag:
<html> <head> <style> h1 { font-size: 24px; color: #000; } </style> </head> <body> <h1>Hey you</h1> </body> </html>
Or the link tag:
<html> <head> <link rel="stylesheet" type="text/css" href="./tests/css/test.css"> </head> <body> <h1>Hey you</h1> </body> </html>
Into this:
<html> <head> <style> h1 { font-size: 24px; color: #000; } </style> </head> <body> <h1 style="font-size: 24px; color: #000;">Hey you</h1> </body> </html>
Installation
This package needs Laravel 9.x.
Begin by installing this package through Composer. Require it directly from the Terminal to take the last stable version:
composer require fedeisas/laravel-mail-css-inliner
At this point the inliner should be already working with the default options. If you want to fine-tune these options, you can do so by publishing the configuration file:
php artisan vendor:publish --provider='Fedeisas\LaravelMailCssInliner\LaravelMailCssInlinerServiceProvider'
and changing the settings on the generated config/css-inliner.php file.
Contributing
- Install project dependencies:
composer install
- Execute tests with the following command:
./vendor/bin/phpunit
Found a bug?
Please, let me know! Send a pull request or a patch. Questions? Ask! I will respond to all filed issues.
Inspiration
This package is greatly inspired, and mostly copied, from SwiftMailer CSS Inliner. I just made an easy drop-in solution for Laravel.
License
This package is open-sourced software licensed under the MIT license
fedeisas/laravel-mail-css-inliner 适用场景与选型建议
fedeisas/laravel-mail-css-inliner 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.82M 次下载、GitHub Stars 达 598, 最近一次更新时间为 2014 年 02 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「mailer」 「css」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 fedeisas/laravel-mail-css-inliner 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fedeisas/laravel-mail-css-inliner 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 fedeisas/laravel-mail-css-inliner 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Twig extension to insert css as inline styles with a tag
Caching and compression for Twig assets (JavaScript and CSS).
Creates new sare mail transport for laravel applications
Define your own css rule-sets for the TYPO3 CMS backend.
Mandrill Api Integration for Yii2
Selectize Theme for Bootstrap 4
统计信息
- 总下载量: 4.82M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 608
- 点击次数: 25
- 依赖项目数: 3
- 推荐数: 11
其他信息
- 授权协议: MIT
- 更新时间: 2014-02-06