From 169bf8788a5e658bf6b940d0604c611504eaf7b9 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Tue, 19 Sep 2023 12:56:08 -0600 Subject: [PATCH] Update code using the settings class --- resources/classes/email.php | 49 ++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/resources/classes/email.php b/resources/classes/email.php index 535b3af24a..a5713dd448 100644 --- a/resources/classes/email.php +++ b/resources/classes/email.php @@ -207,9 +207,17 @@ if (!class_exists('email')) { */ public function send() { + //set the domain_uuid if not set + if (!isset($this->domain_uuid) && isset($_SESSION)) { + $this->domain_uuid = $_SESSION['domain_uuid']; + } + + //get the email queue settings + $setting = new settings(["domain_uuid" => $this->domain_uuid]); + //set the send_method if not already set if (!isset($this->method)) { - if ($this->setting->get('email_queue','enabled') == 'true') { + if ($setting->get('email_queue','enabled') == 'true') { $this->method = 'queue'; } else { @@ -220,11 +228,6 @@ if (!class_exists('email')) { //add the email to the queue if ($this->method == 'queue') { - //set the domain_uuid if not set - if (!isset($this->domain_uuid) && isset($_SESSION)) { - $this->domain_uuid = $_SESSION['domain_uuid']; - } - //add the email_queue_uuid $email_queue_uuid = uuid(); @@ -398,30 +401,30 @@ if (!class_exists('email')) { include_once("resources/phpmailer/class.smtp.php"); //use the email default settings - if (!empty($this->setting->get('email','smtp_hostname'))) { - $smtp['hostname'] = $this->setting->get('email','smtp_hostname'); + if (!empty($setting->get('email','smtp_hostname'))) { + $smtp['hostname'] = $setting->get('email','smtp_hostname'); } - $smtp['host'] = (!empty($this->setting->get('email','smtp_host')) ? $this->setting->get('email','smtp_host'): '127.0.0.1'); - if (!empty($this->setting->get('email','smtp_port'))) { - $smtp['port'] = (int)$this->setting->get('email','smtp_port'); + $smtp['host'] = (!empty($setting->get('email','smtp_host')) ? $setting->get('email','smtp_host'): '127.0.0.1'); + if (!empty($setting->get('email','smtp_port'))) { + $smtp['port'] = (int)$setting->get('email','smtp_port'); } else { $smtp['port'] = 0; } - $smtp['secure'] = $this->setting->get('email','smtp_secure'); - $smtp['auth'] = $this->setting->get('email','smtp_auth'); - $smtp['username'] = $this->setting->get('email','smtp_username'); - $smtp['password'] = $this->setting->get('email','smtp_password'); - $smtp['from'] = $this->setting->get('email','smtp_from'); - $smtp['from_name'] = $this->setting->get('email','smtp_from_name'); - $smtp['validate_certificate'] = $this->setting->get('email','smtp_validate_certificate'); - $smtp['crypto_method'] = $this->setting->get('email','smtp_crypto_method') ?? null; + $smtp['secure'] = $setting->get('email','smtp_secure'); + $smtp['auth'] = $setting->get('email','smtp_auth'); + $smtp['username'] = $setting->get('email','smtp_username'); + $smtp['password'] = $setting->get('email','smtp_password'); + $smtp['from'] = $setting->get('email','smtp_from'); + $smtp['from_name'] = $setting->get('email','smtp_from_name'); + $smtp['validate_certificate'] = $setting->get('email','smtp_validate_certificate'); + $smtp['crypto_method'] = $setting->get('email','smtp_crypto_method') ?? null; - if (!empty($this->setting->get('voicemail','smtp_from')) && !empty($this->setting->get('voicemail','smtp_from'))) { - $smtp['from'] = $this->setting->get('voicemail','smtp_from'); + if (!empty($setting->get('voicemail','smtp_from')) && !empty($setting->get('voicemail','smtp_from'))) { + $smtp['from'] = $setting->get('voicemail','smtp_from'); } - if (!empty($this->setting->get('voicemail','smtp_from_name')) && !empty($this->setting->get('voicemail','smtp_from_name'))) { - $smtp['from_name'] = $this->setting->get('voicemail','smtp_from_name'); + if (!empty($setting->get('voicemail','smtp_from_name')) && !empty($setting->get('voicemail','smtp_from_name'))) { + $smtp['from_name'] = $setting->get('voicemail','smtp_from_name'); } //override the domain-specific smtp server settings, if any