not tested but you could try something like:
$data = array(
'name' => Input::get('name'),
'detail'=>Input::get('detail'),
'sender' => Input::get('sender')
);
$pdf = PDF::loadView('letters.test', $data);
Mail::send('emails.invoice', $data, function($message) use($pdf)
{
$message->from('[email protected]', 'Your Name');
$message->to('[email protected]')->subject('Invoice');
$message->attachData($pdf->output(), "invoice.pdf");
});
Hey,
Currently testing on a local server so can't tell for definite but pretend seems to have made this work. Thanks!
Marc
Just came across this because I'm working on an app that sends pdf invoices, and I'd been struggling with how to attach a dynamically created pdf without having to save it to a temporary file -- which others recommended, and is a very inelegant solution at best. This solution works perfectly!!!
Let me add to it -- I was briefly stumped as to how to also include dynamically provided data to the mail function -- to and from email addresses, and subject. Then I discovered that "use()" will accept more than one argument. So, I can do, "Use($pdf, $data)" where the $data array includes all of the needed mail data. Very cool!
Thanks, alainbelez and Marc. You've made my day! -Steve
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community