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)

4

1 回答 1

3

可能是它的文件路径问题

这对我有用,试试这个它会起作用

$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']);
});
于 2018-01-03T13:07:31.013 回答