未在 Laravel 5 中加载 CSS 已发送电子邮件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30416123/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CSS not loading in Laravel 5 sent email
提问by Sumit
I have included all Bootstrap 3 CSS files and other project related JS and CSS files with unique folder names inside the public
folder. Here's an example of the structure:
我在文件夹中包含了所有 Bootstrap 3 CSS 文件和其他项目相关的 JS 和 CSS 文件,并在public
文件夹中使用了唯一的文件夹名称。下面是一个结构示例:
public/pnotify
public/bower_components/bootstrap
public/ckeditor
I have included all these JS and CSS links with exact path on main template and everything loads correctly through out the project, but when I give a Blade file as view for Laravel 5 mail. The CSS doesn't load and everything is messed up in the received email, while the same Blade file is rendered accurately within project. Is it because I haven't implemented asset management of Laravel and mail system of Laravel loads CSS only from assets or I am missing something? Please some one clarify.
我已经将所有这些 JS 和 CSS 链接都包含在主模板上,并且在整个项目中都正确加载了所有这些 JS 和 CSS 链接,但是当我提供一个 Blade 文件作为 Laravel 5 邮件的视图时。CSS 没有加载,所有内容都在收到的电子邮件中搞砸了,而同一个 Blade 文件在项目中准确呈现。是因为我没有实现 Laravel 的资产管理和 Laravel 的邮件系统仅从资产加载 CSS 还是我遗漏了什么?请有人澄清。
回答by Bogdan
You can link external CSS files in an email, but most likely they will be blocked by the email clients for security reasons. So you'll need to inline the CSS inside your email templates for them to work.
您可以在电子邮件中链接外部 CSS 文件,但出于安全原因,它们很可能会被电子邮件客户端阻止。因此,您需要将 CSS 内联到电子邮件模板中才能使其工作。
You can try using the following package to help make it easier:
您可以尝试使用以下软件包来帮助简化:
回答by junkystu
I've come across this question whilst searching for a CSS inliner myself. Laravel Mail CSS Inlinerseems to work better with Laravel 5 and above. I am currently using it with 5.2 and it's great.
我在自己搜索 CSS 内联程序时遇到了这个问题。Laravel Mail CSS Inliner似乎在 Laravel 5 及更高版本上工作得更好。我目前在 5.2 中使用它,它很棒。
回答by Ramiz Khan
Change the following:
更改以下内容:
return $this->subject('new message')->view('layouts.mail.bussiness_partner')->with('data',$this->data);
to this:
对此:
return $this->subject('new message')->markdown('layouts.mail.bussiness_partner')->with('data',$this->data);
use markdown then it supports bootstrap
使用降价然后它支持引导