company = $company; $this->user = $user; $this->payment = $payment; } /** * Execute the job. * * @return void */ public function handle() { info("entity paid mailer"); //Set DB MultiDB::setDb($this->company->db); //if we need to set an email driver do it now $this->setMailDriver($this->payment->client->getSetting('email_sending_method')); $mail_obj = (new EntityPaidObject($this->payment))->build(); $mail_obj->from = [$this->payment->user->email, $this->payment->user->present()->name()]; //send email Mail::to($this->user->email) ->send(new EntityNotificationMailer($mail_obj)); //catch errors if (count(Mail::failures()) > 0) { $this->logMailError(Mail::failures()); } } private function logMailError($errors) { SystemLogger::dispatch( $errors, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_SEND, SystemLog::TYPE_FAILURE, $this->payment->client ); } }