PHPMailer\PHPMailer\SMTP::getServerExt PHP Method

getServerExt() public method

A multipurpose method The method works in three ways, dependent on argument value and current state 1. HELO/EHLO was not sent - returns null and set up $this->error 2. HELO was sent $name = 'HELO': returns server name $name = 'EHLO': returns boolean false $name = any string: returns null and set up $this->error 3. EHLO was sent $name = 'HELO'|'EHLO': returns server name $name = any string: if extension $name exists, returns boolean True or its options. Otherwise returns boolean False In other words, one can use this method to detect 3 conditions: - null returned: handshake was not or we don't know about ext (refer to $this->error) - false returned: the requested feature exactly not exists - positive value returned: the requested feature exists
public getServerExt ( string $name ) : mixed
$name string Name of SMTP extension or 'HELO'|'EHLO'
return mixed
    public function getServerExt($name)
    {
        if (!$this->server_caps) {
            $this->setError('No HELO/EHLO was sent');
            return null;
        }
        // the tight logic knot ;)
        if (!array_key_exists($name, $this->server_caps)) {
            if ('HELO' == $name) {
                return $this->server_caps['EHLO'];
            }
            if ('EHLO' == $name || array_key_exists('EHLO', $this->server_caps)) {
                return false;
            }
            $this->setError('HELO handshake was used. Client knows nothing about server extensions');
            return null;
        }
        return $this->server_caps[$name];
    }