protected function authNtlm()
    {
        if ( !ezcBaseFeatures::hasExtensionSupport( 'mcrypt' ) )
        {
            throw new ezcBaseExtensionNotFoundException( 'mcrypt', null, "PHP not compiled with --with-mcrypt." );
        }

        // Send NTLM type 1 message
        $msg1 = base64_encode( $this->authNtlmMessageType1( $this->senderHost, $this->serverHost ) );

        $this->sendData( "AUTH NTLM {$msg1}" );
        if ( $this->getReplyCode( $serverResponse ) !== '334' )
        {
            throw new ezcMailTransportSmtpException( 'SMTP server does not accept AUTH NTLM.' );
        }

        // Parse NTLM type 2 message
        $msg2 = base64_decode( trim( substr( $serverResponse, 4 ) ) );
        $parts = array(
                        substr( $msg2, 0, 8 ),  // Signature ("NTLMSSP\0")
                        substr( $msg2, 8, 4 ),  // Message type
                        substr( $msg2, 12, 8 ), // Target name (security buffer)
                        substr( $msg2, 20, 4 ), // Flags
                        substr( $msg2, 24, 8 ), // Challenge
                        substr( $msg2, 32 )     // The rest of information
                      );

        $challenge = $parts[4];

        // Send NTLM type 3 message
        $msg3 = base64_encode( $this->authNtlmMessageType3( $challenge, $this->user, $this->password, $this->senderHost, $this->serverHost ) );

        $this->sendData( $msg3 );
        if ( $this->getReplyCode( $serverResponse ) !== '235' )
        {
            throw new ezcMailTransportSmtpException( 'SMTP server did not allow NTLM authentication.' );
        }
    }