public function connect($timeout = null, $persistent = false)
    {
        $this->greeting = null;

        $result = $this->socket->connect(
            $this->host, $this->port, $persistent, $timeout, $this->socket_options
        );

        if (PEAR::isError($result)) {
            return PEAR::raiseError(
                'Failed to connect socket: ' . $result->getMessage()
            );
        }

        /*
         * Now that we're connected, reset the socket's timeout value for
         * future I/O operations.  This allows us to have different socket
         * timeout values for the initial connection (our $timeout parameter)
         * and all other socket operations.
         */
        if ($this->timeout > 0) {
            if (PEAR::isError($error = $this->setTimeout($this->timeout))) {
                return $error;
            }
        }

        if (PEAR::isError($error = $this->parseResponse(220))) {
            return $error;
        }

        /* Extract and store a copy of the server's greeting string. */
        list(, $this->greeting) = $this->getResponse();

        if (PEAR::isError($error = $this->negotiate())) {
            return $error;
        }

        return true;
    }
public function connect($timeout = null, $persistent = false)
    {
        $this->greeting = null;

        $result = $this->socket->connect(
            $this->host, $this->port, $persistent, $timeout, $this->socket_options
        );

        if (PEAR::isError($result)) {
            return PEAR::raiseError(
                'Failed to connect socket: ' . $result->getMessage()
            );
        }

        /*
         * Now that we're connected, reset the socket's timeout value for
         * future I/O operations.  This allows us to have different socket
         * timeout values for the initial connection (our $timeout parameter)
         * and all other socket operations.
         */
        if ($this->timeout > 0) {
            if (PEAR::isError($error = $this->setTimeout($this->timeout))) {
                return $error;
            }
        }

        if (PEAR::isError($error = $this->parseResponse(220))) {
            return $error;
        }

        /* Extract and store a copy of the server's greeting string. */
        list(, $this->greeting) = $this->getResponse();

        if (PEAR::isError($error = $this->negotiate())) {
            return $error;
        }

        return true;
    }
public function connect ( $ timeout = null , $ persistent = false ) { $ this -> greeting = null ; $ result = $ this -> socket -> connect ( $ this -> host , $ this -> port , $ persistent , $ timeout , $ this -> socket_options ) ; if ( PEAR :: isError ( $ result ) ) { return PEAR :: raiseError ( 'Failed to connect socket: ' . $ result -> getMessage ( ) ) ; } /*
         * Now that we're connected, reset the socket's timeout value for
         * future I/O operations.  This allows us to have different socket
         * timeout values for the initial connection (our $timeout parameter)
         * and all other socket operations.
         */ if ( $ this -> timeout > 0 ) { if ( PEAR :: isError ( $ error = $ this -> setTimeout ( $ this -> timeout ) ) ) { return $ error ; } } if ( PEAR :: isError ( $ error = $ this -> parseResponse ( 220 ) ) ) { return $ error ; } /* Extract and store a copy of the server's greeting string. */ list ( , $ this -> greeting ) = $ this -> getResponse ( ) ; if ( PEAR :: isError ( $ error = $ this -> negotiate ( ) ) ) { return $ error ; } return true ; }
Attempt to connect to the SMTP server.

@param int  $timeout    The timeout value (in seconds) for the
socket connection attempt.
@param bool $persistent Should a persistent socket connection
be used?

@return mixed Returns a PEAR_Error with an error message on any
kind of failure, or true on success.
@since 1.0
Attempt to connect to the SMTP server .