public function startTLS() : bool { set_error_handler(function ($type, $msg) { throw new TransportException('Unable to connect with STARTTLS: ' . $msg); }); try { return stream_socket_enable_crypto($this->stream, true); } finally { restore_error_handler(); } }