I have been trying to move from directly sending emails, to adding them to Laravel Queue
, and I've noticed that if the email contains any files, it does not really like to deal with it.
For example, this example works fine if I was to send the email directly, but it will not if I want to add it to the Queue
because it will not serialise the $file
variable.
$this->mail->queue('emails.contact-us',compact('data'), function($message) use($files)
{
$message->from('email@mail.co.uk', 'Test Subject');
foreach($files as $file){
$message->attach($file->getRealPath(),array(
'as' => $file->getClientOriginalName(),
'mime' => $file->getMimeType()
));
}
});
If I tried to getFileContents
, store all data to a varaible and pass the variable to the Queue
, it will create a Job
, however instead of the Json
payload data that it should produce, it adds 0
to the payload
column.
So my question is, has anybody dealt with this situation before? I have thought about adding file temporary, but it does not seem like a good solution.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire