我正在使用Laravel 4开发一个站点,并希望在测试期间向自己发送临时电子邮件,但是似乎发送电子邮件的唯一方法是查看视图。
可以做这样的事情吗?
Mail::queue('This is the body of my email', $data, function($message)
{
$message->to('[email protected]', 'John Smith')->subject('This is my subject');
});
如Laravel邮件的答案中所述:传递字符串而不是view,您可以执行此操作(从Jarek的答案中逐字复制代码):
Mail::send([], [], function ($message) {
$message->to(..)
->subject(..)
// here comes what you want
->setBody('Hi, welcome user!');
});
您还可以通过将其放入app / views / email / blank.blade.php中来使用空视图
{{{ $msg }}}
没有别的。然后你编码
Mail::queue('email.blank', array('msg' => 'This is the body of my email'), function($message)
{
$message->to('[email protected]', 'John Smith')->subject('This is my subject');
});
这样一来,您就可以从应用程序的不同部分发送自定义的空白电子邮件,而不必为每个电子邮件创建不同的视图。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句