company = $company; $this->user = $user; $this->invitation = $invitation; $this->entity = $invitation->{$entity_type}; $this->entity_type = $entity_type; $this->settings = $invitation->contact->client->getMergedSettings(); $this->template = $template; } /** * Execute the job. * * @return void */ public function handle() { nlog("entity sent mailer"); /*If we are migrating data we don't want to fire these notification*/ if ($this->company->is_disabled) { return true; } //Set DB MultiDB::setDb($this->company->db); //if we need to set an email driver do it now $this->setMailDriver(); $mail_obj = (new EntitySentObject($this->invitation, $this->entity_type, $this->template))->build(); $mail_obj->from = [config('mail.from.address'), config('mail.from.name')]; try { Mail::to($this->user->email) ->send(new EntityNotificationMailer($mail_obj)); } catch (\Exception $e) { $this->failed($e); $this->logMailError($e->getMessage(), $this->entity->client); } } }