params = $params; } /** * Execute the job. * * @return void */ public function handle() { $params = $this->params; $email = $params['email']; $subject = $params['subject']; Mail::send( $params['template_name'], $params['template_value'], function ($message) use($email, $subject) { $message->to($email)->subject($subject); } ); MailLog::create([ 'email' => $params['email'], 'subject' => $params['subject'], 'template_name' => $params['template_name'], 'error' => count(Mail::failures()) > 0 ? Mail::failures()[0] : NULL ]); } }