Ya creamos el catalogo de empresas, ahora vamos a ir creando un modulo de configuración de correo electrónico

Primero creamos el archivo del modelo en app/Models/SettingsMailModel.php con el siguiente contenido

<?php

namespace App\Models;

use CodeIgniter\Model;

class SettingsMailModel extends Model
{
    protected $table      = 'mailsettings';
    protected $primaryKey = 'id';

    protected $useAutoIncrement = true;

    protected $returnType     = 'array';
    protected $useSoftDeletes = true;

    protected $allowedFields = ['id', 'email', 'host', 'smtpDebug', 'SMTPAuth', 'port', 'created_at', 'deleted_at', 'updated_at', 'smptSecurity', 'pass'];
}

Para la tabla donde se guardara la información corremos el siguiente código SQL en PHPMYADMIN en nuestra base de datos, en publicaciones posteriores les dejare los archivos de migración para que no tengan la necesidad de correr archivos SQL y sirva para diferentes motores de base de datos

-- phpMyAdmin SQL Dump
-- version 5.0.4
-- https://www.phpmyadmin.net/
--
-- Servidor: 127.0.0.1
-- Tiempo de generación: 18-04-2023 a las 00:56:17
-- Versión del servidor: 10.4.17-MariaDB
-- Versión de PHP: 7.4.15

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Base de datos: `wheelsoft`
--

-- --------------------------------------------------------

--
-- Estructura de tabla para la tabla `mailsettings`
--

CREATE TABLE `mailsettings` (
  `id` int(11) NOT NULL,
  `email` varchar(512) DEFAULT NULL,
  `host` varchar(128) DEFAULT NULL,
  `smtpDebug` varchar(16) DEFAULT NULL,
  `SMTPAuth` varchar(16) DEFAULT NULL,
  `port` varchar(16) DEFAULT NULL,
  `created_at` datetime DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  `smptSecurity` varchar(64) DEFAULT NULL,
  `pass` varchar(128) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Volcado de datos para la tabla `mailsettings`
--

INSERT INTO `mailsettings` (`id`, `email`, `host`, `smtpDebug`, `SMTPAuth`, `port`, `created_at`, `deleted_at`, `updated_at`, `smptSecurity`, `pass`) VALUES
(1, 'mail@domain.com', 'mail.host5.com', '1', '1', '587', NULL, NULL, NULL, 'tls', 'password');

--
-- Índices para tablas volcadas
--

--
-- Indices de la tabla `mailsettings`
--
ALTER TABLE `mailsettings`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT de las tablas volcadas
--

--
-- AUTO_INCREMENT de la tabla `mailsettings`
--
ALTER TABLE `mailsettings`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

Creamos el archivo app/controllers/SettingsMailController.php con el siguiente contenido

<?php

namespace julio101290\boilerplate\Controllers\Users;

namespace App\Controllers;

use CodeIgniter\API\ResponseTrait;
use CodeIgniter\Controller;
use App\Models\SettingsMailModel;
use App\Models\LogModel;
use julio101290\boilerplate\Controllers\BaseController;
use julio101290\boilerplate\Entities\Collection;
use julio101290\boilerplate\Models\GroupModel;
use CodeIgniter\Config\Services;
use App\Models\RegisterModel;
use App\Controllers\RegisterController;
use PHPMailer\PHPMailer;

/**
 * Class UserController.
 */
class SettingsMailController extends BaseController
{

    use ResponseTrait;

    /** @var \agungsugiarto\boilerplate\Models\GroupModel */
    protected $group;
    protected $settingsMail;
    protected $log;
    protected $register;
    protected $registerController;
    protected $custumer;

    /** @var \agungsugiarto\boilerplate\Models\UserModel */
    protected $users;

    public function __construct()
    {
        $this->group = new GroupModel();
        $this->log = new LogModel();
        $this->settingsMail = new SettingsMailModel();
        $autorize = $this->authorize = Services::authorization();
        helper('menu');
    }

    public function index()
    {




        $datos = $this->settingsMail->where("id", 1)->first();

        $data["title"] = "Correo Electronicos";
        $data["subtitle"] = "Configuraciones de Correo Electronico";
        $data["data"] = $datos;

        return view('mailSettings', $data);
    }

    /** 
    public function sendMailPDF($uuid)
    {

        //DATOS CORREO
        $datos = $this->settingsMail->where("id", 1)->first();

        //DATOS  REGISTRO

        $register = $this->register->select("*")->where("uuid", $uuid)->first();

        $custumer = $this->custumer->select("*")->where("id", $register["custumer"])->first();

        $mailsTarjets = "";

        $correo = $datos["email"];
        $SMTPDebug = $datos["smtpDebug"];
        $host = $datos["host"];

        if ($datos["SMTPAuth"] == 1) {
            $SMTPAuth = true;
        } else {
            $SMTPAuth = false;
        }

        $puerto = $datos["port"];
        $clave = $datos["pass"];

        $SMTPSeguridad = $datos["smptSecurity"];

        // Load Composer's autoloader
        // Instantiation and passing `true` enables exceptions
        $mail = new PHPMailer\PHPMailer();

        try {


            //Server settings
            $mail->SMTPDebug = $SMTPDebug;                      // Enable verbose debug output
            $mail->isSMTP();                                            // Send using SMTP
            $mail->Host = $host;                    // Set the SMTP server to send through
            $mail->SMTPAuth = $SMTPAuth;                                   // Enable SMTP authentication
            $mail->Username = $correo;                     // SMTP username
            $mail->Password = $clave;                               // SMTP password
            $mail->SMTPSecure = $SMTPSeguridad;         // Enable TLS encryption; `PHPMailer::ENCRYPTION_SMTPS` also accepted
            $mail->Port = $puerto;

            $nombreEmpresa = "";
            // TCP port to connect to
            //Recipients
            $mail->setFrom($correo, $nombreEmpresa);

            if ($custumer["email1"] != "") {
                try {
                    $mailAddress = $mail->addAddress($custumer["email1"], '');

                    if (!$mailAddress) {

                        echo "Error con el correo Electronico";
                        return;
                    }
                } catch (Exception $ex) {

                    echo $ex->getMessage();
                }
            }

            if ($custumer["email2"] != "") {

                try {
                    $mailAddress = $mail->addAddress($custumer["email2"], '');

                    if (!$mailAddress) {

                        echo "Error con el correo Electronico";
                        return;
                    }
                } catch (Exception $ex) {

                    echo $ex->getMessage();
                }
            }

            if ($custumer["email3"] != "") {

                try {
                    $mailAddress = $mail->addAddress($custumer["email3"], '');

                    if (!$mailAddress) {

                        echo "Error con el correo Electronico";
                        return;
                    }

                    if (!$mailAddress) {

                        echo "Error con el correo Electronico";
                        return;
                    }
                } catch (Exception $ex) {

                    echo $ex->getMessage();
                }
            }

            if ($custumer["email4"] != "") {

                try {
                    $mailAddress = $mail->addAddress($custumer["email4"], '');

                    if (!$mailAddress) {

                        echo "Error con el correo Electronico";
                        return;
                    }
                } catch (Exception $ex) {

                    echo $ex->getMessage();
                }
            }

            if ($custumer["email5"] != "") {

                try {
                    $mailAddress = $mail->addAddress($custumer["email5"], '');

                    if (!$mailAddress) {

                        echo "Error con el correo Electronico";
                        return;
                    }
                } catch (Exception $ex) {

                    echo $ex->getMessage();
                }
            }
            // Add a recipient
            //$mail->addReplyTo('info@example.com', 'Information');
            //mail->addCC('cc@example.com');
            //$mail->addBCC('bcc@example.com');
            // Attachments
            $attachment = $this->registerController->report($uuid, 1);
            $mail->AddStringAttachment($attachment, 'registro' . $register["codeCustumer"] . '.pdf', 'base64', 'application/pdf');

            // Add attachments
            //$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
            // Content
            $mail->isHTML(true);                                  // Set email format to HTML
            $mail->Subject = "Envio de Registro";
            $mail->Body = "Adjuntamos el registro de verificación de neumaticos";
            $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

            try {
                $send = $mail->send();
            } catch (Exception $ex) {

                echo $ex->getMessage();
                return;
            }

            if ($send) {
                echo 'Correo Enviado Correctamente';
            } else {
                echo 'Error al enviar el correo';
            }
        } catch (Exception $e) {
            echo "Error al enviar el correo: {$e->ErrorInfo}";
        }
    }
*/
    public function guardar()
    {


        helper('auth');
        $userName = user()->username;
        $idUser = user()->id;

        //GUARDA CONFIGURACIONES
        $this->settingsMail->update(1, $_POST);

        //  return redirect()->to("/admin/hospital");
        return redirect()->back()->with('sweet-success', 'Actualizado Correctamente');
        // return redirect()->back()->with('sweet-success','Guardado Correctamente');
    }
}

Creamos el archivo app/views/mailSettings.php con el siguiente contenido

<?= $this->extend('julio101290\boilerplate\Views\layout\index') ?>

<!-- Section content -->
<?= $this->section('content') ?>



<section class="content">
    <div class="container-fluid">
        <div class="row">

            <div class="col-md-12">

                <div class="card card-primary">
                    <div class="card-header">
                        <h3 class="card-title">Configuración Correo Electrónico</h3>
                    </div>



                    <form action="<?= base_url('admin/mailSettings') ?>/save" method="post">
                        <?= csrf_field() ?>

                        <div class="card-body">


                            <div class="form-group">
                                <label for="nombreEmpresa">E-Mail</label>
                                <input type="text" class="form-control" id="email" value="<?= $data["email"] ?>" name="email" placeholder="Inserte el Email">
                            </div>

                            <div class="form-group">
                                <label for="correoElectronico">Host</label>
                                <input type="text" class="form-control" value="<?= $data["host"] ?>" id="host" name="host" placeholder="Host">
                            </div>

                            <div class="form-group">
                                <label for="smtpDebug">Debug Client</label>
                                <select id="smtpDebug" name="smtpDebug">

                                    <option value="0">DEBUG_OFF</option>

                                    <option value="1">DEBUG_CLIENT</option>

                                    <option value="2">DEBUG_SERVER</option>

                                </select>

                            </div>

                            <div class="form-group">
                                <label for="SMTPAuth">SMTP Auth</label>
                                <select id="SMTPAuth" name="SMTPAuth">


                                    <option value=""></option>

                                    <option value="0">Sin autentificación</option>

                                    <option value="1">Con autentificación</option>


                                </select>

                            </div>


                            <div class="form-group">
                                <label for="smptSecurity">Seguridad</label>
                                <select id="smptSecurity" name="smptSecurity">


                                    <option value="">Sin Seguridad</option>
                                    <option value="ssl">Seguridad SSL</option>
                                    <option value="tls">Seguridad TLS</option>

                                </select>

                            </div>


                            <div class="form-group">
                                <label for="port">Puerto</label>
                                <input type="number" class="form-control" value="<?= $data["port"] ?>" id="port" name="port" placeholder="Puerto">
                            </div>

                            <div class="form-group">
                                <label for="port">Contraseña</label>
                                <input type="password" class="form-control" value="<?= $data["pass"] ?>" id="pass" name="pass" placeholder="Contraseña">
                            </div>


                        </div>

                        <div class="card-footer">
                            <button type="submit" class="btn btn-primary btnGuardar">Guardar</button>
                        </div>
                    </form>
                </div>





            </div>



        </div>

    </div>
</section>


<?= $this->endSection() ?>


<?= $this->section('js') ?>
<script>
    $("#smptSecurity").val("<?= $data["smptSecurity"] ?>");
    $("#SMTPAuth").val("<?= $data["SMTPAuth"] ?>");
    $("#smtpDebug").val("<?= $data["smtpDebug"] ?>");
</script>
<?= $this->endSection() ?>

en app/config/routes.php agregamos el siguiente codigo

 $routes->resource('emailSettings', [
        'filter' => 'permission:email-permiso',
        'controller' => 'SettingsMailController',
    ]);
    
    $routes->post('mailSettings/save', 'SettingsMailController::guardar');
    
    //Para futuros envios
    //$routes->get('mailSettings/sendMail/(:any)', 'SettingsMailController::sendMailPDF/$1');
Y listo ya tenemos nuestro modulo de configuración solo tenemos que ajustar unos permisos y roles
Video Demostrativo