Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

marian_d_dev's avatar

Laravel scheduler send email daily with pdf attachment

Hi guys, I am generating pdf files from blade views using dompdf. I want to use scheduler to automatically send emails and to attach those pdf files. Is there any solution? Is there any method to generated pdf files from blade view, attach them to email and schedule sending this emails daily?

0 likes
2 replies
deepu07's avatar

@marian_d_dev generate a pdf doc by using dompdf and save in storage/pdf dir and write a cron job with an email template attach the generated pdf from storage/pdf and after email sent, delete the pdf from storage direc. if you have multiple pdf docs make a zip file and attach it to the email. like this

Mail::send('emails.pdf', function($message) use ($path) {
            $message->to('[email protected]', 'testuser')->subject
            ('pdf Report '. Carbon::now()->format('m-d-Y'));
            $message->attach($path);
            $message->from('[email protected]','test-tech');
        });
Storage::disk('pdf')->delete(Storage::disk('pdf')->allFiles());
1 like

Please or to participate in this conversation.