How can external settings be properly implemented in PHPMailer classes to prevent overrides during updates?

To prevent overrides of external settings during updates in PHPMailer classes, it is recommended to utilize a separate configuration file for storing external settings. This way, updates to the PHPMailer classes will not affect the external settings, as they are stored in a separate file.

// config.php
<?php
define('MAIL_HOST', 'smtp.example.com');
define('MAIL_USERNAME', 'username@example.com');
define('MAIL_PASSWORD', 'password');

// index.php
<?php
require 'config.php';

use PHPMailer\PHPMailer\PHPMailer;

$mail = new PHPMailer();
$mail->isSMTP();
$mail->Host = MAIL_HOST;
$mail->Username = MAIL_USERNAME;
$mail->Password = MAIL_PASSWORD;

// Rest of the PHPMailer code