public function sendFixture($infile, $outfile, $user, $client, $from, $to, $host, $params = array()) { $_SERVER['argv'] = array($_SERVER['argv'][0], '--sender=' . $from, '--recipient=' . $to, '--user='******'--host=' . $host, '--client=' . $client); $in = file_get_contents($infile, 'r'); $tmpfile = Horde_Util::getTempFile('KolabFilterTest'); $tmpfh = @fopen($tmpfile, 'w'); if (empty($params['unmodified_content'])) { @fwrite($tmpfh, sprintf($in, $from, $to)); } else { @fwrite($tmpfh, $in); } @fclose($tmpfh); $inh = @fopen($tmpfile, 'r'); /* Setup the class */ if (empty($params['incoming'])) { require_once 'Horde/Kolab/Filter/Content.php'; $parser = new Horde_Kolab_Filter_Content(); } else { require_once 'Horde/Kolab/Filter/Incoming.php'; $parser = new Horde_Kolab_Filter_Incoming(); } ob_start(); /* Parse the mail */ $result = $parser->parse($inh, 'echo'); if (empty($params['error'])) { $this->assertNoError($result); $this->assertTrue(empty($result)); $output = ob_get_contents(); ob_end_clean(); $out = file_get_contents($outfile); $replace = array('/^Received:.*$/m' => '', '/^Date:.*$/m' => '', '/DTSTAMP:.*$/m' => '', '/^--+=.*$/m' => '----', '/^Message-ID.*$/m' => '----', '/boundary=.*$/m' => '----', '/\\s/' => ''); foreach ($replace as $pattern => $replacement) { $output = preg_replace($pattern, $replacement, $output); $out = preg_replace($pattern, $replacement, $out); } if (empty($params['unmodified_content'])) { $this->assertEquals(sprintf($out, $from, $to), $output); } else { $this->assertEquals($out, $output); } } else { $this->assertError($result, $params['error']); } }
#!/usr/bin/env php <?php /** * A filter for incoming mail on a Kolab Server. It checks the * messages for iCal data and handles automatic invitations. * * Copyright 2004-2008 Klarälvdalens Datakonsult AB * * See the enclosed file COPYING for license information (LGPL). If you * did not receive this file, see http://www.horde.org/licenses/lgpl21. * * @package Kolab */ /** Kolab filter library */ require_once 'Horde/Kolab/Filter/Incoming.php'; require_once 'Horde/Kolab/Filter/Response.php'; /* Parse the mail */ $parser = new Horde_Kolab_Filter_Incoming(); $response = new Horde_Kolab_Filter_Response(); $result = $parser->parse(); if (is_a($result, 'PEAR_Error')) { $response->handle($result); } exit(0);