定制 bweston92/laravel-inline-css-mailer 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bweston92/laravel-inline-css-mailer

最新稳定版本:v0.1

Composer 安装命令:

composer require bweston92/laravel-inline-css-mailer

包简介

Laravel CSS to Inline HTML.

README 文档

README

Installation

Just require the package and you're good to go! There is one core issue and that's Laravel doesn't allow sending plain HTML e-mails with-out it being a view, so you need to create a view file like below.

views/emails/raw.blade.php

{{ $content }}

Dependencies

This is just a wrapper for Laravel around the actual CSS inliner package found at 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);
        });
    }

}

Wait whats captures?

The CSS is found in multiple places, in code, local files, remote files over http, remote files ftp? This package comes with a raw capture and a file capture. Your own implementation for other methods will probably be better, just implement the capture interface.

  • Raw new \BW\L4CssInline\Capture\RawCapture('body {background: #000;}')
  • Local file new \BW\L4CssInline\Capture\FileCapture('/var/www/css/styles.css')

(All the CSS in style tags will be parsed aswell)

Contributing

Just stick to the standards which is the same as Laravel's code base.

License

This package open-sourced software licensed under the MIT license

统计信息

  • 总下载量: 1.53k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 7
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-02-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固