[exim] Squirrelmail tricks to configure Exim for Personal Fi…

Página Principal
Apagar esta mensagem
Responder a esta mensagem
Autor: Marc Perkel
Data:  
Para: Frank S. Bernhardt, exim-users
CC: 
Assunto: [exim] Squirrelmail tricks to configure Exim for Personal Filter
ok - so - here's what I did with Exim and Squirrelmail to make it so
that you can use Squirrelmail to create personal exim filters. This is a
very simple plugin and can probably be addapted to do all kinds of cool
things.

first - go to your Squirrelmail plugins directory and create a directory
called "personal_filter"

Then - in that directory - create these two files.

setup.php
----------------------------
<?php

// Required for installation of hook into SM
function squirrelmail_plugin_init_personal_filter()
{
global $squirrelmail_plugin_hooks;

$squirrelmail_plugin_hooks['optpage_register_block']['personal_filter']
= 'personal_filter_optionLink';
}


// Create the title, link and desc on the SM options page
function personal_filter_optionLink()
{
   global $optpage_blocks;
   $optpage_blocks[] = array(
         'name' => _("Personal Exim Filter"),
         'url' => '../plugins/personal_filter/options.php',
         'desc' => _("View and edit your personal Exim email filter. 
This is still experimental and you
shouldn't use this until you fully understand it. Documentation coming."),
         'js' => FALSE
   );
}


?>
----------------------

options.php
-------------------

<?php

define('SM_PATH', '../../');
require_once(SM_PATH . 'include/validate.php');
require_once(SM_PATH . 'functions/page_header.php');
$filterFileName = $data_dir . $username . ".filter";
?>

<html>
<?php displayPageHeader($color, 'None'); ?>

<br>
<table width=95% align=center border=0 cellpadding=2 cellspacing=0><tr><td
 bgcolor="<?php echo $color[0] ?>">
         <center><b><?php echo _("Options") . " - " . _("Personal 
Filter") ?></b></center>
      </td></tr>
<tr><td>
<?php
if(!is_array($_POST))
   global $_POST;
if(!is_array($_SERVER))
   global $_SERVER;
$PHP_SELF = $_SERVER["PHP_SELF"];


if(isset($_POST["action"]) && $_POST["action"] == "editList")
{
   $filterFile = $_POST["filterFile"];
   echo "<p>";
   switch(writeList($filterFile, $filterFileName))
   {
      case TRUE:
          echo "<b><i>" . _("Your personal filter has been updated!") . 
"</i></b>";
          break;
      default:
          echo "<b><i>" . _("There was an error updating your personal 
filter!  Please try again or report this
error to your system administrator if this problem continues!") . 
"</i></b>";
   }
   echo "</p>\n";
}
?>


<p>
<?php echo _("This is your current personal Exim email filter. It uses
the <a href=http://www.exim.org
target=_blank><b>Exim</b></a> filter language to allow you to create
your own personal email filters. Click on
\"Save\" when done.") ?>
</p>

<p align="center">
<form action="<?php echo $PHP_SELF; ?>" method="POST">
<input type="hidden" name="action" value="editList">
<textarea name="filterFile" rows="15" cols="60">
<?php @readfile($filterFileName); ?>
</textarea><br>
<input type="submit" name="submit" value="<?php echo _("Save") ?>">
</form></p></td></tr></table>
</body>
</html>

<?php
// Given the update list, $list, write it to the file, $file
function writeList($list, $file)
{
   if($fp = fopen($file, "w"))
   {
      fputs($fp, $list);
      if($list != "")
         fputs($fp, "\n");
   }
   return fclose($fp);
}
?>
--------------------------------


Once you created these two files - then run your conf.pl and include the
plugin. At this point you chould have a text window for creating and
editing personal filters.

Then - all you need to do is add a router that will find the filter and
run it. On my system this router works.

# Virtual forwarding using squirrelmail interface

virtual_userforward:
driver = redirect
# Edit for location of your prefs files
file = /etc/squirrelmail/prefs/$local_part@$domain.filter
no_verify
no_expn
user = mail
skip_syntax_errors
allow_filter
allow_fail
forbid_pipe
file_transport = address_file
pipe_transport = address_pipe
reply_transport = address_reply

So - it works so far - probably could use some improvement like syntax
error reporting and such.

Let me know if anyone uses this and if they like it and if they have
improvements.