payment = $payment; $this->contact = $contact; $this->company = $company; $this->settings = $payment->client->getMergedSettings(); } /** * Execute the job. * * * @return void */ public function handle() { if($this->company->is_disabled) return true; if ($this->contact->email) { MultiDB::setDb($this->company->db); //if we need to set an email driver do it now $this->setMailDriver(); $email_builder = (new PaymentEmailEngine($this->payment, $this->contact))->build(); try{ $mail = Mail::to($this->contact->email, $this->contact->present()->name()); $mail->send(new TemplateEmail($email_builder, $this->contact->user, $this->contact->client)); }catch(\Exception $e) { info("mailing failed with message " . $e->getMessage()); event(new PaymentWasEmailedAndFailed($this->payment, $this->company, Mail::failures(), Ninja::eventVars())); $this->failed($e); return $this->logMailError($e->getMessage(), $this->payment->client); } event(new PaymentWasEmailed($this->payment, $this->payment->company, Ninja::eventVars())); } } }