我猜想pricequote是可郵寄類,那麼你的pricequote可郵寄類應該是這樣的:
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class pricequote extends Mailable
{
use Queueable, SerializesModels;
/**
* The data for the email instance.
*
* @var data
*/
protected $data;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($data)
{
$this->data = $data;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->view('yourview')
->with(['data' => $this->data]);
}
}
然後在你的控制器,可以發送電子郵件這樣的:
Mail::to("[email protected]")->send(new pricequote($data));
Laravel 5.1:
您可以選擇您要發送的視圖,如下所示:
$params = array(
'name' => $name, //user's data
'email' => $email,
'phone' => $phone,
'data' => $data, //other stuffs in the form
);
Mail::send('view', $params, function($m){
$m->to($this->argument('to_email'));
});
第一個參數是視圖,第二個參數是要在視圖上訪問的數據。
對不起,我忘了補充:5.4 – Feralheart
更新我的L5.4答案。 – Troyer