简体   繁体   中英

How to queue email in a job with attachment laravel

I have created a queue job to send an email to my batch of users it works fine when I send an email with an attachment. But when I add the file to queue I get an error that says unable to serialize content.

这是我运行代码时的错误消息 and here is my code

$emailJob = (new SendNewsletter($id, $request->flag, $attachments))->delay(Carbon::now()->addSeconds(3));
        dispatch($emailJob);

You should not include your file in the job directly. Rather do something like this:

  1. Store the file on disk
  2. Create a job using the file path of the file on disk
  3. When processing the job:
    1. Retrieve the file from disk
    2. Send your newsletter
    3. Delete the file from disk

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM