protected function _startTls()
{
$secure = $this->getParam('secure');
if ($this->isSecureConnection() || $secure !== true && $secure !== 'tls') {
return false;
}
if (!$this->queryExtension('STARTTLS')) {
if ($secure === true) {
return false;
}
throw new Horde_Smtp_Exception(Horde_Smtp_Translation::r("Server does not support TLS connections."), Horde_Smtp_Exception::LOGIN_TLSFAILURE);
}
$this->_connection->write('STARTTLS');
$this->_getResponse(220, array('error' => 'logout'));
if (!$this->_connection->startTls()) {
$this->logout();
$e = new Horde_Smtp_Exception();
$e->setSmtpCode(454);
throw $e;
}
$this->_debug->info('Successfully completed TLS negotiation.');
$this->setParam('secure', 'tls');
return true;
}