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

Jorge_19's avatar

How to send PDF files using QUEUES?

I have problems sending emails through queues and would like help with the behavior or handling of queues to send PDF files uploaded from a form and / or PDF created with DOMPDF.

0 likes
4 replies
bobbybouwmann's avatar
Level 88

Well sending an email requires a file stored on a server. So whenever you upload or generate a PDF you store it somewhere on your server. Than you put the email on the queue in a job for example. The job should then fetch the pdf and send it along with the email. This way the stuff on your queue is small and fast and you can send the email using a queue.

jekinney's avatar

Do this quite a bit. Laravel has helpers for attachments which if you use, shouldn't be an issue.

But as @bobbybouwmann stated the files need to be available at the time the email is sent to attach it to.

https://laravel.com/docs/5.8/mail#attachments

Next time, probably easier to help if you post the error and/or exact issue you're having. Laravel makes it really easy if you use the helpers to send emails with any data and attachments.

FYI every email service uses Queues to send emails, even MS Exchange Server. So it a normal thing.

Jorge_19's avatar

Use the following command line to create the mail with queue.

"php artisan make:mail ContactEmploymentEmail --markdown=emails.employment-email"

And I have the following error when selecting the attachment in the form and submitting it.

"Serialization of 'Illuminate\Http\UploadedFile' is not allowed"

this happens when using markdown

bobbybouwmann's avatar

So the problem here is that you don't save the file first. You currently send the posted data (UploadedFile) to the job, but that is not possible. You first need to save the file to your filesystem. Then you can queue a job that sends the email. The email itself should get the file from the filesystem and attach it to the email.

Let me know if that works for you!

Please or to participate in this conversation.