AFP548

Using avelsieve to edit Sieve filters in SquirrelMail on 10.5

Leopard Server has all of the pieces installed for sieve filters for server-side mail filtering, but if you want to use the SquirrelMail filter interface to allow users to add filters, then you have to do a little work.  We've provided a pkg to install the avelsieve package that allows you to install it the plugin to SquirrelMail, but it is a bit incompatible with 10.5 Server.  

Read on to see how to resolve it….

If you have gotten used to using server side mail filters using Sieve and squirrelmail, you'll probably notice that existing rules work fine in Leopard Server, but if you create a new rule you'll get the dreaded "Did not specify legal script data length" when trying to save the new rule. This is due to a change in PHP5 in how curly brackets are quoted in PHP scripts. But fear not. There are 2 solutions:
  1. Use the existing avelsieve package provide here on AFP548, and make a slight modifications to it to fix the quoting incompatibility.
  2. Use the more full featured dev release of avelsieve (v. 1.9.7 at the writing of this). 

Both work fine.  I like the cleaner interface to 1.9.7 in SquirrelMail, but it is a dev release, so caution is advised.  I'll provide instructions on how to get both working.

Option 1: Use the existing avelsieve.pkg:

If you already have it installed due to a server upgrade, skip steps 1-3, and just edit the sieve-php.lib.php file in step 4.

1.  Download the avelsieve package here and install on the server.  It dumps its files in /usr/share/squirrelmail/plugins, which is sym linked by /etc/squirrelmail/plugins -> /usr/share/squirrelmail/plugins. 

2.   Activate the plugins via the config.pl script in /etc/squirrelmail/config:

<span class="Apple-style-span">s</span>udo perl&nbsp;/etc/squirrelmail/config/conf.pl<br />

Choose option (8) for Plugins

select "avelsieve".

This adds the correct configuration line to  /etc/squirrelmail/config.php.

3.  Set the correct authentication type.  Edit /etc/squirrelmail/plugins/avelsieve/config.php and change:

<span class="Apple-style-span">&#36;</span>preferred_mech = &quot;PLAIN&quot;;<br />

 to

<span class="Apple-style-span">&nbsp;</span>&#36;preferred_mech = &quot;CRAM-MD5&quot;;<br />

If you are using PLAIN or LOGIN, set it to that, but most likely it will be CRAM-MD5. 

4.  Edit the /etc/squirrelmail/plugins/avelsieve/lib/sieve-php.lib.php file. Find the line:

    fputs($this->fp, "PUTSCRIPT \"$scriptname\" \{$len+}\r\n"); 

 

and change it to :

 

    fputs($this->fp, "PUTSCRIPT \"$scriptname\"".' {'."$len+".'}'."\r\n");

 
The issue is the quoting of the curly bracket.  The output of this iine is supposed to be something like:
PUTSCRIPT "PHPSCRIPT" {503+}  but instead comes out as:
 
PUTSCRIPT "PHPSCRIPT" \{503+}

 
 The changes above simply concatenating the curly brackets instead of escaping them.  From what I can see in the PHP bug database, this is expected behavior.  
 
 Head over to http://<your domain>/webmail, sign in, and you should now be able to add filters again.

 Option 2: Use the dev version:

1.  Go to http://email.uoa.gr/projects/squirrelmail/avelsieve_download.php and download the latest dev version.  As of this writing, it is version 1.9.7. Hopefully it will soon be 2.0 and part of the stable release.

2.  If you currently have avelsieve installed in, move it out of the way:

<span class="Apple-style-span">s</span>udo mv /usr/share/squirrelmail/plugins/avelsieve /usr/share/squirrelmail/plugins/avelsieve.old<br />

3.  copy avelsieve-1.9.7.tar.gz to /usr/share/squirrelmail/plugins and unzip and untar it.  You should now have a new avelsieve folder in /usr/share/squirrelmail/plugins.

4. Change the owner to www:staff and permissions to something sane like 744. 

4. The config file is in a bit of a different location, and is a different format than the prior version of avelsieve.  Copy /etc/squirrelmail/plugins/avelsieve/config/config_sample.php to /etc/squirrelmail/plugins/avelsieve/config/config.php. 

5.  Edit this  config.php and change the authenication type to :

<span class="Apple-style-span">&nbsp;</span>&#36;sieve_preferred_sasl_mech = &#39;CRAM-MD5&#39;;<br />

Head over to http://<your domain>/webmail, sign in, and you should now see the new interface and be able to add filters.

Timothy Perfitt

Timothy Perfitt is currently the head of Twocanoes Software, Inc, creator of iOS and Mac apps for the IT market. Prior to Twocanoes Software, he survived the collapse of the dot com era by jumping from Coolboard.com to Apple, Inc in 2001. He worked on the initial certification training materials for Mac OS X, worked in Education Sales, and then finished his time at Apple in 2012 working with Fortune 500 customers to integrate Macs and iOS devices into complex environments. He is a returned Peace Corps volunteer, serving in the Solomon Islands as a math and science teacher from 1991 to 1993.

More Posts - Website

Follow Me:

Exit mobile version