I suppose the pricequote is the mailable class, then your pricequote mailable class should look like:
<?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]);
}
}
Then in your controllers you can send the email like this:
Mail::to("[email protected]")->send(new pricequote($data));
Laravel 5.1:
You can choose the view you want to send as email like this:
$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'));
});
The first argument is the view and second the data you want to have access on the view.