I am working on sending email function. Firstly, I want to generate .pdf file from my view. Then I want to attach the generated .pdf file by email without saving it into disk. I use below in my controller:
$pdf = PDF::loadView('getpdf', $data);
Mail::to($to_email)->send(new Mysendmail($post_title, $full_name))
->attachData($pdf->output(), "newfilename.pdf");
And I get this error: "Call to a member function attachData() on null"
If I use below without attachment, it works well:
$pdf = PDF::loadView('getpdf', $data);
Mail::to($to_email)->send(new Mysendmail($post_title, $full_name));
Please advise.