bweston92 / laravel-inline-css-mailer
此包已被弃用且不再维护。没有推荐替代包。
此包最新版本(v0.1)没有可用的许可信息。
Laravel CSS 转换为内联 HTML。
v0.1
2015-02-19 14:20 UTC
Requires
This package is not auto-updated.
Last update: 2017-10-23 14:44:35 UTC
README
安装
只需引入包即可!有一个核心问题,那就是 Laravel 不允许发送不带视图的纯 HTML 电子邮件,因此您需要创建一个如下视图文件。
views/emails/raw.blade.php
{{ $content }}
依赖关系
这是一个包装 Laravel 的实际 CSS 内联包,位于 https://github.com/tijsverkoyen/CssToInlineStyles
examples.php
class MyEmailSender {
/**
* @var \BW\L4CssInline\CssInlineMailer
*/
protected $mailer;
/**
* @param \BW\L4CssInline\CssInlineMailer $mailer
*/
public function __construct(CssInlineMailer $mailer)
{
$this->mailer = $mailer;
}
/**
* This example assumes there is a style tag in the view.
*
* @param NotificationInterface $notification
*/
public function sendNotification(NotificationInterface $notification)
{
$this->mailer->send('emails.notification', compact('notification'), function($message) use ($notification)
{
$message->to($notification->getUser()->email);
});
}
/**
* This example is passing css into the mailer.
*
* @param UserInterface $$user
*/
public function sendWelcomeEmail(UserInterface $user)
{
$this->mailer->addCss(new \BW\L4CssInline\CssCapture\RawCapture('body {background: #000;}'));
$this->mailer->send('emails.welcome-user', compact('user'), function($message) use ($user)
{
$message->to($user->email, $user->fullName);
});
}
}
等待捕获什么?
CSS 存在于多个地方,在代码、本地文件、通过 http 的远程文件、通过 ftp 的远程文件?此包包含原始捕获和文件捕获。您自己的实现可能更好,只需实现捕获接口。
- 原始
new \BW\L4CssInline\Capture\RawCapture('body {background: #000;}')
- 本地文件
new \BW\L4CssInline\Capture\FileCapture('/var/www/css/styles.css')
(所有在 style 标签中的 CSS 都将被解析)
贡献
只需遵循标准,这与 Laravel 的代码库相同。
许可
此软件包为开源软件,根据 MIT 许可证 发布。