[英]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.