Update code using the settings class

This commit is contained in:
FusionPBX 2023-09-19 12:56:08 -06:00 committed by GitHub
parent 4b9ff10eef
commit 169bf8788a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 23 deletions

View File

@ -207,9 +207,17 @@ if (!class_exists('email')) {
*/ */
public function send() { 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 //set the send_method if not already set
if (!isset($this->method)) { if (!isset($this->method)) {
if ($this->setting->get('email_queue','enabled') == 'true') { if ($setting->get('email_queue','enabled') == 'true') {
$this->method = 'queue'; $this->method = 'queue';
} }
else { else {
@ -220,11 +228,6 @@ if (!class_exists('email')) {
//add the email to the queue //add the email to the queue
if ($this->method == '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 //add the email_queue_uuid
$email_queue_uuid = uuid(); $email_queue_uuid = uuid();
@ -398,30 +401,30 @@ if (!class_exists('email')) {
include_once("resources/phpmailer/class.smtp.php"); include_once("resources/phpmailer/class.smtp.php");
//use the email default settings //use the email default settings
if (!empty($this->setting->get('email','smtp_hostname'))) { if (!empty($setting->get('email','smtp_hostname'))) {
$smtp['hostname'] = $this->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'); $smtp['host'] = (!empty($setting->get('email','smtp_host')) ? $setting->get('email','smtp_host'): '127.0.0.1');
if (!empty($this->setting->get('email','smtp_port'))) { if (!empty($setting->get('email','smtp_port'))) {
$smtp['port'] = (int)$this->setting->get('email','smtp_port'); $smtp['port'] = (int)$setting->get('email','smtp_port');
} }
else { else {
$smtp['port'] = 0; $smtp['port'] = 0;
} }
$smtp['secure'] = $this->setting->get('email','smtp_secure'); $smtp['secure'] = $setting->get('email','smtp_secure');
$smtp['auth'] = $this->setting->get('email','smtp_auth'); $smtp['auth'] = $setting->get('email','smtp_auth');
$smtp['username'] = $this->setting->get('email','smtp_username'); $smtp['username'] = $setting->get('email','smtp_username');
$smtp['password'] = $this->setting->get('email','smtp_password'); $smtp['password'] = $setting->get('email','smtp_password');
$smtp['from'] = $this->setting->get('email','smtp_from'); $smtp['from'] = $setting->get('email','smtp_from');
$smtp['from_name'] = $this->setting->get('email','smtp_from_name'); $smtp['from_name'] = $setting->get('email','smtp_from_name');
$smtp['validate_certificate'] = $this->setting->get('email','smtp_validate_certificate'); $smtp['validate_certificate'] = $setting->get('email','smtp_validate_certificate');
$smtp['crypto_method'] = $this->setting->get('email','smtp_crypto_method') ?? null; $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'))) { if (!empty($setting->get('voicemail','smtp_from')) && !empty($setting->get('voicemail','smtp_from'))) {
$smtp['from'] = $this->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'))) { if (!empty($setting->get('voicemail','smtp_from_name')) && !empty($setting->get('voicemail','smtp_from_name'))) {
$smtp['from_name'] = $this->setting->get('voicemail','smtp_from_name'); $smtp['from_name'] = $setting->get('voicemail','smtp_from_name');
} }
//override the domain-specific smtp server settings, if any //override the domain-specific smtp server settings, if any