Support the ongoing development of Laravel.io →
posted 10 years ago
Mail
Last updated 1 year ago.
0

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");
});
Last updated 1 year ago.
0

Hey,

Currently testing on a local server so can't tell for definite but pretend seems to have made this work. Thanks!

Marc

Last updated 1 year ago.
0

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

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.