I am working on jobs (queue) with Laravel 5.7. I have scheduled emails for every weekends into jobs table. For email scheduler I have stored all email information like From, to , reply-to email address along with body of the email into jobs table.
Here I have added by Job class
use Dispatchable,
InteractsWithQueue,
Queueable,
SerializesModels;
protected $details;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct() {
$this->details = $details;
}
/**
* Execute the job.
*
* @return void
*/
public function handle() {
//
$payload = json_decode($event->job->getRawBody());
$data = unserialize($payload->data->command);
echo $data;
exit;
Mail::send(
['html' => 'emails.templates'], array('body' => $body, 'title' => $post_data['subject']), function($message) use ($post_data, $employee, $clientName, $docName, $filename) {
$message->to($post_data['email'], $clientName)->subject($post_data['subject']);
$message->from('xxxx', $employee->first_name . " " . $employee->last_name);
$message->replyTo($employee->email);
}
);
echo "send Email";
exit;
}
Now, When Job handle function executed I am facing issue with get content of email for sending email. Here is code for get email content
$payload = json_decode($event->job->getRawBody());
$data = unserialize($payload->data->command);
But this code is not working. My aim is get that email content use that content for sending emails.
Or if you have any other solutions or options for send emails. Please share your idea as well.
Thanks you in advance.