HEX
Server: Apache
System: Linux hz.vslconceptsdomains.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: dkfounda (3233)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/local/mailchannels/load.php
<?php
namespace MailChannels;

use Katzgrau\KLogger\Logger;
use Net_DNS2_Resolver;
use Net_DNS2_Exception;
use Psr\Log\LogLevel;

$config = App::getConfig();

App::setVerifySSL($config::VERIFY_SSL);
App::setLogger(new Logger($config::LOG_FOLDER, $config::LOG_LEVEL));
$contextValue = '{context}';
$logFormat = json_encode([
    'datetime' => '{date}',
    'logLevel' => '{level}',
    'message' => '{message}',
    'context' => $contextValue,
]);
$logFormat = str_replace("\"$contextValue\"", $contextValue, $logFormat);
App::setOutboundFailureLogger(new Logger($config::LOG_FOLDER, LogLevel::DEBUG, array(
    'filename' => 'outbound-failures.txt',
    'appendContext' => false,
    'logFormat' => $logFormat,
)));
App::setLockFolder($config::LOCK_FOLDER);

$storage = new FileStorage($config::FILE_STORAGE_FOLDER);

App::setStorage($storage);

$whmHost = $config::WHM_HOST;
if (!$whmHost) {
    $whmHost = $_SERVER["HTTP_HOST"];
}

$b64Token = file_get_contents($config::ACCESS_HASH_FILE);
$token = base64_decode($b64Token);

App::setInboundAPIClientBuilder(
    (new InboundAPIImplBuilder())
        ->setBaseURI(Config::INBOUND_API_URL)
);

$whmAPI = new WHMAPI1JsonImpl($whmHost, $config::WHM_USERNAME, $token, $config::WHM_API_VERSION);
$cpanel2API = new Cpanel2JsonImpl($whmHost, $config::WHM_USERNAME, $token, $config::WHM_API_VERSION);


// TODO: The only use that I could find of the resolver configured below was removed
//       in commit b6fa0e31a502e348340fce110e17b9607b78a751. I'm leaving this code here
//       for now, because I want to minimize risk while deploying the fix for IDNS, but
//       it should be removed later.
try {
    $nameservers = $whmAPI->getNameServerConfig();
    $nameservers = array_map(function($element) {
        return gethostbyname($element);
    }, $nameservers);

    App::setResolver(new Net_DNS2_Resolver(array('nameservers' => $nameservers)));
} catch (WHMApiBadStatusException $e) {
    App::getLogger()->warning("Couldn't retrieve the nameservers from the whm api: " . $e->getMessage());
} catch (Net_DNS2_Exception $e) {
    App::getLogger()->error("Error configuring resolver: " . $e->getMessage());
}

ServiceSelector::registerService(new InboundSMTPServiceWHM68Impl($whmAPI,$cpanel2API), InboundSMTPService::class);
ServiceSelector::registerService(new OutboundSMTPServiceImpl(new EximConfigurer($config::EXIM_CONF, $config::EXIM_CONF_LOCAL), $whmAPI), OutboundSMTPService::class);