[英]How to cache email html on laravel?
我正在使用laravel框架,我需要将HTML保存到缓存文件,.html或其他文件中,以在浏览器中显示,而不是在新闻邮件中单击链接。 (链接:在浏览器中查看电子邮件)。
在integration.blade.php中包含@include('emails/header')
和@include('emails/footer')
这是邮件发送代码:
Mail::send('emails/integration', array('type' => ucfirst($type)), function($message) use ($type)
{
$message->to( Auth::user()->email, Auth::user()->fullname)->subject('Successful name and '.ucfirst($type).' store integration!');
});
在此之后,我需要缓存html。
在浏览器链接中查看电子邮件,就像address.com/email/?html=gbfvisbiudoanlfdlsakdnlsakndlasn
您可以使用自定义HTML使用Laravel在发送电子邮件中使用的主要原理,但是在创建视图之后可以对其进行缓存:
$minutes = ...
$viewData = [
'type' => ucfirst($type)
];
$html = Cache::remember('email/integration', $minutes, function()
{
return View::make('email/integration', $viewData)->render();
});
Mail::send('emails.echo', ['html' => $html], function($message) use ($type)
{
$message->to(Auth::user()->email, Auth::user()->fullname)->subject('Successful name and '.ucfirst($type).' store integration!');
});
代码未经测试,但我确定您能理解。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.