From 6314ddd1365899e60205d6cdbfaa490ae36f067c Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 9 Jun 2008 11:21:03 +0000 Subject: [PATCH] Updated mail methods to use new sieve TLS option. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11264 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../mail/class_mail-methods-cyrus.inc | 2 +- .../mail/personal/mail/sieve/class_sieve.inc | 27 ++++++++++++++++++- .../mail/sieve/class_sieveManagement.inc | 3 ++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/gosa-plugins/mail/personal/mail/class_mail-methods-cyrus.inc b/gosa-plugins/mail/personal/mail/class_mail-methods-cyrus.inc index c73154f64..4022b03d7 100644 --- a/gosa-plugins/mail/personal/mail/class_mail-methods-cyrus.inc +++ b/gosa-plugins/mail/personal/mail/class_mail-methods-cyrus.inc @@ -275,7 +275,7 @@ class mailMethodCyrus extends mailMethod /* Log into the mail server */ $sieve= new sieve($cfg["sieve_server"], $cfg["sieve_port"], $user, - $cfg["password"], $cfg["admin"]); + $cfg["password"], $cfg["admin"],$cfg["sieve_option"]); if (!$sieve->sieve_login()){ msg_dialog::display(_("SIEVE error"), sprintf(_("Cannot log into SIEVE server: %s"), '

'.to_string($sieve->error_raw).''), ERROR_DIALOG); diff --git a/gosa-plugins/mail/personal/mail/sieve/class_sieve.inc b/gosa-plugins/mail/personal/mail/sieve/class_sieve.inc index c45d0f18e..666ef1c0e 100644 --- a/gosa-plugins/mail/personal/mail/sieve/class_sieve.inc +++ b/gosa-plugins/mail/personal/mail/sieve/class_sieve.inc @@ -82,6 +82,7 @@ class sieve var $error; var $error_raw; var $responses; + var $options = ""; //maybe we should add an errorlvl that the user will pass to new sieve = sieve(,,,,E_WARN) //so we can decide how to handle certain errors?!? @@ -199,7 +200,7 @@ class sieve } /* end else */ } /* end get_response() */ - function sieve($host, $port, $user, $pass, $auth="", $auth_types="PLAIN DIGEST-MD5") + function sieve($host, $port, $user, $pass, $auth="",$options ="", $auth_types="PLAIN DIGEST-MD5") { $this->host=$host; $this->port=$port; @@ -220,6 +221,7 @@ class sieve $this->loggedin=false; $this->error= ""; $this->error_raw=""; + $this->options = $options; } function parse_for_quotes($string) @@ -477,9 +479,32 @@ class sieve return true; } + function authenticate() { + /* Check if a TLS bases connection is required + */ + if(preg_match("/^tls$/",$this->options)){ + + /* Check if PHP supports TLS encryption for sockets + */ + if(function_exists("stream_socket_enable_crypto")){ + + if (@ fputs ($this->fp, "STARTTLS\r\n") === false) { + $this->error_raw = "fputs() returned 'false'"; return (false); + } @ $linha = fgets ($this->fp, 1024); if ($linha === false) { + $this->error_raw = "fgets() returned 'false'"; return (false); + } if (! preg_match ("/\\s*OK\\s/i", $linha)) { + $this->error_raw = "expected an 'OK', but server replied: '" . trim ($linha) . "'"; return (false); + } if (! @ stream_socket_enable_crypto ($this->fp, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { + $this->error_raw = "stream_socket_enable_crypto() returned 'false'"; return (false); + }else{ + echo "Done"; + } + } + } + switch ($this->auth_in_use) { case "PLAIN": diff --git a/gosa-plugins/mail/personal/mail/sieve/class_sieveManagement.inc b/gosa-plugins/mail/personal/mail/sieve/class_sieveManagement.inc index a47cd4bda..fa829e575 100644 --- a/gosa-plugins/mail/personal/mail/sieve/class_sieveManagement.inc +++ b/gosa-plugins/mail/personal/mail/sieve/class_sieveManagement.inc @@ -143,7 +143,8 @@ class sieveManagement extends plugin $cfg["sieve_port"], $this->parent->$uattrib, $cfg["password"], - $cfg["admin"]); + $cfg["admin"], + $cfg["sieve_option"]); /* Try to login */ if (!@$this->sieve_handle->sieve_login()){ -- 2.30.2