PHPMailer\PHPMailer

PHPMailer::serverHostname()protectedWP 1.0

Get the server hostname. Returns 'localhost.localdomain' if unknown.

Method of the class: PHPMailer{}

No Hooks.

Return

String.

Usage

// protected - for code of main (parent) or child class
$result = $this->serverHostname();

PHPMailer::serverHostname() code WP 6.4.3

protected function serverHostname()
{
    $result = '';
    if (!empty($this->Hostname)) {
        $result = $this->Hostname;
    } elseif (isset($_SERVER) && array_key_exists('SERVER_NAME', $_SERVER)) {
        $result = $_SERVER['SERVER_NAME'];
    } elseif (function_exists('gethostname') && gethostname() !== false) {
        $result = gethostname();
    } elseif (php_uname('n') !== false) {
        $result = php_uname('n');
    }
    if (!static::isValidHost($result)) {
        return 'localhost.localdomain';
    }

    return $result;
}