?? GreyFile — Mystic File Browser

Current path: home/webdevt/www/demo2/wp-content/plugins/divi-contact-form-helper/d5/server/Admin/Controllers/



?? Go up: /home/webdevt/www/demo2/wp-content/plugins/divi-contact-form-helper/d5/server/Admin

?? Viewing: SMTPManager.php

<?php

namespace KS_PAC_DCFH\Admin\Controllers;

use PHPMailer\PHPMailer\PHPMailer;

if (!defined('ABSPATH')) {
    exit;
}

class SMTPManager
{
    public function load(): void
    {
        add_action('phpmailer_init', [$this, 'setup_phpmailer'], 10, 1);
    }

    public function setup_phpmailer(PHPMailer $php_mailer): void
    {
        $settings = ks_pac_dcfh_app()->settings_rep();
        if (
            !$settings->is_setting_enabled('smtp_understanding_confirmed') ||
            !$settings->is_setting_enabled('is_smtp_host_enabled')
        ) {
            return;
        }
        $php_mailer->isSMTP();
        //$php_mailer->CharSet = 'UTF-8';
        //$php_mailer->isHTML(true);
        $php_mailer->SMTPKeepAlive = true;
        $php_mailer->Host = $settings->get_setting('smtp_host');
        $php_mailer->Port = (int)$settings->get_setting('smtp_port');
        // Authentication
        if ($settings->is_setting_enabled('is_smtp_authentication_enabled')) {
            $php_mailer->SMTPAuth = true;
            $php_mailer->Username = $settings->get_setting('smtp_username');
            $php_mailer->Password = $settings->get_setting('smtp_password');
        } else {
            $php_mailer->SMTPAuth = false;
        }
        // Encryption
        $encryption = $settings->get_setting('smtp_encryption');
        switch ($encryption) {
            case 'ssl':
                $php_mailer->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
                $php_mailer->SMTPAutoTLS = false;
                break;
            case 'tls':
                $php_mailer->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
                $php_mailer->SMTPAutoTLS = true;
                break;
            default:
                $php_mailer->SMTPSecure = false;
                $php_mailer->SMTPAutoTLS = false;
                break;
        }
        // FROM handling (WordPress-safe)
        add_filter('wp_mail_from', function () use ($settings) {
            return $settings->get_setting('smtp_from_email');
        });
        add_filter('wp_mail_from_name', function () use ($settings) {
            return $settings->get_setting('smtp_from_name');
        });
    }
}


??

??