PHPMailer\PHPMailer

SMTP::connected()publicWP 1.0

Check connection state.

Method of the class: SMTP{}

No Hooks.

Return

true|false. True if connected

Usage

$SMTP = new SMTP();
$SMTP->connected();

SMTP::connected() code WP 6.5.2

public function connected()
{
    if (is_resource($this->smtp_conn)) {
        $sock_status = stream_get_meta_data($this->smtp_conn);
        if ($sock_status['eof']) {
            //The socket is valid but we are not connected
            $this->edebug(
                'SMTP NOTICE: EOF caught while checking if connected',
                self::DEBUG_CLIENT
            );
            $this->close();

            return false;
        }

        return true; //everything looks good
    }

    return false;
}