我可以使用Laravel 5.8中的默认模板进行电子邮件验证。
现在,我要自定义电子邮件。
你能帮我吗?
我尝试遵循以下指示:https://medium.com/@lordgape/custom-verification-email-notification-laravel-5-8-573ba3183ead。没有错误,但是没有发送电子邮件。
当我切换回默认验证时,将发送默认电子邮件。
编辑:
到目前为止我尝试过的步骤:
by.addLocator('lid', function(value, parentElement) {
var nodes;
if(parentElement)
nodes = parentElement.querySelectorAll();
else
nodes = document.querySelectorAll('body *');
return Array.prototype.filter.call(nodes, function(node) {
if( node.hasAttribute("lid") && node.getAttribute('lid') === value)
return node;
});
});
VerifyEmail::toMailUsing(function ($notifiable){
$verifyUrl = URL::temporarySignedRoute(
'verification.verify',
Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)),
['id' => $notifiable->getKey()]
);
// dd($notifiable);
return new EmailVerification($verifyUrl, $notifiable);
});
答案 0 :(得分:0)
如果您只想自定义已发送电子邮件的外观和布局,而不自定义邮件的内容(文本)必须发布通知和邮件组件的视图文件。
为此,您可以输入:
php artisan vendor:publish --tag=laravel-notifications
php artisan vendor:publish --tag=laravel-mail
这些命令会将Laravel邮件模板从供应商文件夹复制到resources/views/vendor/notifications
和resources/views/vendor/mail
。
在原路径中,您拥有email.blade.php
,它基本上是 MailMessage布局。 (实际上,您可以看到可以使用MailMessage自定义的所有可用插槽)。
在后期路径中,您可以找到 markdown 和 html 组件(我在前面提到的MailMessage布局中也使用了这些组件)。您可以查看各种文件并进行修改。
注意:对这些模板所做的更改将应用于您发送的任何电子邮件,并且即使您创建新的通知并可以邮寄,它仍会使用这些修改后的模板。
您可以使用此方法对电子邮件的外观进行全局更改,例如,自定义标题以包括您公司的徽标等。
如果只需要编辑电子邮件的内容(文本),则仍应创建自定义通知/可邮寄邮件。
快速提示:您不必在所有时间都触发通知,因此可以在浏览器中预览电子邮件以快速调整布局和文本,因为:https://medium.com/@jaouad_45834/preview-your-emails-notifications-in-browser-laravel-9058d8c856c4