diff --git a/program/lib/Roundcube/rcube_imap_generic.php b/program/lib/Roundcube/rcube_imap_generic.php index 612265047..91d5dadb0 100644 --- a/program/lib/Roundcube/rcube_imap_generic.php +++ b/program/lib/Roundcube/rcube_imap_generic.php @@ -978,6 +978,14 @@ class rcube_imap_generic $this->prefs['timeout'] = max(0, intval(ini_get('default_socket_timeout'))); } + if ($this->debug) { + // set connection identifier for debug output + $this->resourceid = strtoupper(substr(md5(microtime() . $host . $this->user), 0, 4)); + + $_host = ($this->prefs['ssl_mode'] == 'tls' ? 'tls://' : '') . $host . ':' . $this->prefs['port']; + $this->debug("Connecting to $_host..."); + } + if (!empty($this->prefs['socket_options'])) { $context = stream_context_create($this->prefs['socket_options']); $this->fp = stream_socket_client($host . ':' . $this->prefs['port'], $errno, $errstr, @@ -1000,14 +1008,8 @@ class rcube_imap_generic $line = trim(fgets($this->fp, 8192)); - if ($this->debug) { - // set connection identifier for debug output - preg_match('/#([0-9]+)/', (string) $this->fp, $m); - $this->resourceid = strtoupper(substr(md5($m[1].$this->user.microtime()), 0, 4)); - - if ($line) { - $this->debug('S: '. $line); - } + if ($this->debug && $line) { + $this->debug('S: '. $line); } // Connected to wrong port or connection error? diff --git a/program/lib/Roundcube/rcube_smtp.php b/program/lib/Roundcube/rcube_smtp.php index cfa326b6f..4831caed3 100644 --- a/program/lib/Roundcube/rcube_smtp.php +++ b/program/lib/Roundcube/rcube_smtp.php @@ -114,6 +114,9 @@ class rcube_smtp if ($rcube->config->get('smtp_debug')) { $this->conn->setDebug(true, array($this, 'debug_handler')); $this->anonymize_log = 0; + + $_host = ($use_tls ? 'tls://' : '') . $smtp_host . ':' . $smtp_port; + $this->debug_handler($this->conn, "Connecting to $_host..."); } // register authentication methods