From 7a4513da7da6626a4e4663ed5da428265d977afc Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Fri, 31 Mar 2017 12:32:28 +0300 Subject: [PATCH] Refactor reply_to setting --- app/Models/Traits/SendsEmails.php | 9 +++++++++ app/Ninja/Mailers/ContactMailer.php | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Models/Traits/SendsEmails.php b/app/Models/Traits/SendsEmails.php index 2510373de0c5..7f6a8e8e59fa 100644 --- a/app/Models/Traits/SendsEmails.php +++ b/app/Models/Traits/SendsEmails.php @@ -182,4 +182,13 @@ trait SendsEmails return Domain::getEmailFromId($this->domain_id); } + + public function getReplyToEmail() + { + if (! $this->isPro()) { + return false; + } + + return $this->reply_to_email; + } } diff --git a/app/Ninja/Mailers/ContactMailer.php b/app/Ninja/Mailers/ContactMailer.php index 765f660f6dd9..bc2cbaa4cd55 100644 --- a/app/Ninja/Mailers/ContactMailer.php +++ b/app/Ninja/Mailers/ContactMailer.php @@ -199,7 +199,7 @@ class ContactMailer extends Mailer } $subject = $this->templateService->processVariables($subject, $variables); - $fromEmail = $account->reply_to_email ?: $user->email; + $fromEmail = $account->getReplyToEmail() ?: $user->email; $view = $account->getTemplateView(ENTITY_INVOICE); $response = $this->sendTo($invitation->contact->email, $fromEmail, $account->getDisplayName(), $subject, $view, $data); @@ -291,7 +291,7 @@ class ContactMailer extends Mailer $data['invoice_id'] = $payment->invoice->id; $view = $account->getTemplateView('payment_confirmation'); - $fromEmail = $account->reply_to_email ?: $user->email; + $fromEmail = $account->getReplyToEmail() ?: $user->email; if ($user->email && $contact->email) { $this->sendTo($contact->email, $fromEmail, $accountName, $subject, $view, $data);