/** * Connects to the sieve server. * * @throws Ingo_Exception */ protected function _connect() { if (!empty($this->_sieve)) { return; } $auth = empty($this->_params['admin']) ? $this->_params['username'] : $this->_params['admin']; $this->_sieve = new Net_Sieve($auth, $this->_params['password'], $this->_params['hostspec'], $this->_params['port'], $this->_params['logintype'], $this->_params['euser'], $this->_params['debug'], false, $this->_params['usetls'], null, array($this, 'debug')); $res = $this->_sieve->getError(); if ($res instanceof PEAR_Error) { unset($this->_sieve); throw new Ingo_Exception($res); } /* BC for older Net_Sieve versions that don't allow specify the debug * handler in the constructor. */ if (!empty($this->_params['debug'])) { Ingo_Exception_Pear::catchError($this->_sieve->setDebug(true, array($this, 'debug'))); } }
$host = 'localhost'; $port = "2000"; //you can create a file called passwords.php and store your $user,$pass,$host and $port values in it // or you can modify this script @(include_once "./passwords.php"); $sieve_script_name1 = 'test script1'; // The script $sieve_script1 = "require \"fileinto\";\n\rif header :contains \"From\" \"@cnba.uba.ar\" \n\r{fileinto \"INBOX.Test1\";}\r\nelse \r\n{fileinto \"INBOX\";}"; $sieve_script_name2 = 'test script2'; $sieve_script2 = "require \"fileinto\";\n\rif header :contains \"From\" \"@cnba.uba.ar\" \n\r{fileinto \"INBOX.Test\";}\r\nelse \r\n{fileinto \"INBOX\";}"; $sieve_script1 = "require \"vacation\";\nvacation\n:days 7\n:addresses [\"matthew@de-construct.com\"]\n:subject \"This is a test\"\n\"I'm on my holiday!\nsadfafs\";"; //$sieve=new Net_Sieve($user, $passwd, $host , $port , 'PLAIN'); //$sieve=new Net_Sieve($user, $passwd, $host , $port, 'DIGEST-MD5' ); //$sieve=new Net_Sieve($user, $passwd, $host , $port); $sieve = new Net_Sieve(); $sieve->setDebug(true); if (PEAR::isError($error = $sieve->connect($host, $port))) { echo " there was an error trying to connect to the server. The error is: " . $error->getMessage() . "\n"; exit; } //if(PEAR::isError($error = $sieve->login($user, $passwd , 'PLAIN' , '', false ) ) ){ if (PEAR::isError($error = $sieve->login($user, $passwd, null, '', false))) { echo " there was an error trying to connect to the server. The error is: " . $error->getMessage() . "\n"; exit; } // I list the scripts that I Have installed echo "These are the scripts that I have in the server:\n"; print_r($sieve->listScripts()); echo "\n"; echo "I remove script 1 ({$sieve_script_name1})......\n"; if (!PEAR::isError($error = $sieve->removeScript($sieve_script_name1))) {