根据documentation,要更改电子邮件css,只需在html/themes
目录中编写一个新的CSS文件,然后更改邮件配置文件的主题选项。
在我的应用程序中有两个区域设置。每个语言环境都有不同的css样式。我的问题是:如何根据应用程序区域设置在运行时更改css主题?
答案 0 :(得分:3)
感谢apokryfos,解决方法是在config([ "mail.markdown.theme" => "sometheme" ])
之前致电$user->notify(new CustomNotification())
。
我的错误是在config([ "mail.markdown.theme" => "sometheme" ])
通知类中调用toMail($notifiable)
。
答案 1 :(得分:0)
这可与Laravel 5.7一起使用
假设您在/resources/views/vendor/mail/html/themes/
中有多个CSS文件:
themes
>default.css
>funky_table.css
您可以在构建方法中设置主题。
public function build()
{
$this->theme = 'funky_table';
return $this->markdown(...
这也适用于查询。
答案 2 :(得分:-2)
外部CSS主要被电子邮件客户端阻止。
使用内联css更好,有可用的包laravel-mail-css-inliner