使用 Laravel,根据 to the documentation ,我可以通过 Controller 返回一个 Mailable
以在浏览器中显示它。它有助于预览邮件。
有没有办法在浏览器中预览邮件通知?
我试过:
return (new MyNotification())->toMail($some_user);
但它不起作用:
The Response content must be a string or object implementing __toString(), "object" given.
最佳答案
在你 Controller 的函数中:
$message = (new \App\Notifications\MyNotification())->toMail('example@gmail.com');
$markdown = new \Illuminate\Mail\Markdown(view(), config('mail.markdown'));
return $markdown->render('vendor.notifications.email', $message->data());
只需更改通知类的名称(必要时还可以传递参数)并在浏览器中点击 url 以查看预览。
关于php - 在浏览器中预览邮件通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48620631/