public function connect($credentials = [])
    {
        if ($diff = array_diff(array_keys($this->settings), array_keys($credentials))) {
            throw new \Exception("Missing credentials, the following fields are missing ".implode('/', $diff));
        }

        $this->settings = array_merge($this->settings, $credentials);

        if (isset($this->settings['port']) === false) {
            $this->settings['port'] = 143;
        }

        $this->conn = @imap_open('{'.$this->settings['server'].':'.$this->settings['port'].'/notls}',
            $this->settings['username'], $this->settings['password']);

        if ($this->conn == false) {
            throw new \Exception("Could not connect or authorize to ".$this->settings['server'].':'.$this->settings['port']);
        }

        return ($this->conn != null);
    }
public function connect($credentials = [])
    {
        if ($diff = array_diff(array_keys($this->settings), array_keys($credentials))) {
            throw new \Exception("Missing credentials, the following fields are missing ".implode('/', $diff));
        }

        $this->settings = array_merge($this->settings, $credentials);

        if (isset($this->settings['port']) === false) {
            $this->settings['port'] = 143;
        }

        $this->conn = @imap_open('{'.$this->settings['server'].':'.$this->settings['port'].'/notls}',
            $this->settings['username'], $this->settings['password']);

        if ($this->conn == false) {
            throw new \Exception("Could not connect or authorize to ".$this->settings['server'].':'.$this->settings['port']);
        }

        return ($this->conn != null);
    }
public function connect ( $ credentials = [ ] ) { if ( $ diff = array_diff ( array_keys ( $ this -> settings ) , array_keys ( $ credentials ) ) ) { throw new \ Exception ( "Missing credentials, the following fields are missing " . implode ( '/' , $ diff ) ) ; } $ this -> settings = array_merge ( $ this -> settings , $ credentials ) ; if ( isset ( $ this -> settings [ 'port' ] ) === false ) { $ this -> settings [ 'port' ] = 143 ; } $ this -> conn = @ imap_open ( '{' . $ this -> settings [ 'server' ] . ':' . $ this -> settings [ 'port' ] . '/notls}' , $ this -> settings [ 'username' ] , $ this -> settings [ 'password' ] ) ; if ( $ this -> conn == false ) { throw new \ Exception ( "Could not connect or authorize to " . $ this -> settings [ 'server' ] . ':' . $ this -> settings [ 'port' ] ) ; } return ( $ this -> conn != null ) ; }
Open a connection to a mail server.

@param array $credentials

@return bool
@throws \Exception
Open a connection to a mail server .