1

I am using the lastest build of October CMS with DynamicPDf plugin by Renatio.

I want to generate a PDF and sent it as attachment. I didn't find anything about this in the documentation so I don't know if it's possible.

The sample code to download is the following:

function pdf()
{
    return PDF::loadTemplate('renatio::invoice')->download('download.pdf');
}

I tried to save it and attach it using the default October mail but it didn't work.

Mail::send('acme.blog::mail.welcome', $data, function ($message) {
    $message->attach($pathToFile);
});

Thank you for your help. (If you know a better method just tell me)

1 Answers1

3

May be its file path issue

This is working for me try this it will work

$temp_file = tempnam(sys_get_temp_dir(), 'inv');
PDF::loadTemplate('renatio::invoice')
    ->save($temp_file);

Mail::send('acme.blog::mail.welcome', $data, function ($message) {
    $message->attach($temp_file, ['as' => 'Your_Invoice.pdf']);
});
Hardik Satasiya
  • 9,547
  • 3
  • 22
  • 40