/** * Start TLS negotiation on the current connection. * * Returns true if the TLS connection was successfully * established. * * @throws Protocol\Exception * if the server returned a negative response. * @throws Connection_Exception * if the TLS negotiation has failed. * @return bool */ protected function _starttls() { $this->_send("STARTTLS"); $resp = $this->_getResponse(true); if ($this->_isResponseOk($resp, 220) === false) { throw new Protocol\Exception("The server returned a negative response to the STARTTLS command: {$resp}"); } parent::_starttls(); return true; }
/** * Start TLS negotiation on the current connection. * * Returns true if the TLS connection was successfully * established. * * @throws Protocol\Exception * if the server returned a negative response to the STLS * (STARTTLS) command * or if the TLS negotiation has failed. * @return bool */ protected function _starttls() { $this->_isServerCapable("STLS"); $this->_validateState(self::STATE_AUTHORIZATION, 'STLS'); $this->_send("STLS"); $resp = $this->_getResponse(); if ($this->_isResponseOk($resp) !== true) { throw new Protocol\Exception("The server returned a negative response to the STLS command: {$resp}"); } parent::_starttls(); return true; }