作者热门文章
- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在使用 Laravel 4 开发网站并想在测试期间给自己发送临时电子邮件,但发送电子邮件的唯一方法似乎是通过 View 。
有没有可能做这样的事情?
Mail::queue('This is the body of my email', $data, function($message)
{
$message->to('foo@example.com', 'John Smith')->subject('This is my subject');
});
最佳答案
正如在 Laravel mail: pass string instead of view 上的回答中提到的那样,您可以这样做(从 Jarek 的回答中逐字复制代码):
Mail::send([], [], function ($message) {
$message->to(..)
->subject(..)
// here comes what you want
->setBody('Hi, welcome user!');
});
你也可以使用空 View ,把它放到 app/views/email/blank.blade.php
{{{ $msg }}}
除此之外别无其他。然后你编码
Mail::queue('email.blank', array('msg' => 'This is the body of my email'), function($message)
{
$message->to('foo@example.com', 'John Smith')->subject('This is my subject');
});
这允许您从应用程序的不同部分发送自定义空白电子邮件,而无需为每个部分创建不同的 View 。
关于php - 如何在不使用 View 的情况下使用 Laravel 4 发送电子邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25394476/
我是一名优秀的程序员,十分优秀!