Friday, January 8, 2010

Using SquirrelMail or RoundCube server side rules on Snow Leopard Server

Apple Snow Leopard Server comes with a very limited Mail Sieve rule management within the wiki application.
If you are disappointed by Snow Leopard Servers cappabilities to manage sieve rules (Server Side Mail Rules), there are solutions available.

Prerequisites
Enable Server Side Rules in Mail Server
Start Server Admin
Mail > Settings > Advanced: Tick "PLAIN" on IMAP/POP and save it
Mail > Settings > Filters: Tick "Enable Server Side mail rules", save it and restart the mail service.

Squirrelmail
SquirrelMail is the default webmailer in SLS. You can use the plugin avelsieve to manage server side mail rules. Download avelsieve (I recommend version 1.9.9) and unpack in directory /usr/share/squirrelmail/plugins (so that directory avelsieve is within the plugins dir).
Note that you also need to download javascript_libs plugin, if you use a recent version (>=1.9.8) of avelsieve.
If you need the javascript_libs plugin, also unpack it in squirrelmail's plugins dir.

Then edit the file plugins/avelsieve/config/config.php (copy config_sample.php to config.php if not exisiting).
Change the authentication mechanism to:
$sieve_preferred_sasl_mech = 'PLAIN';

Edit file /usr/share/squirrelmail/config/config.php and register the plugin(s):
$plugins[0] = 'avelsieve';
$plugins[1] = 'javascript_libs'; // only if using a newer version of avelsieve. See avelsieve page

Access the Webmailer (http://<SLS_server_name>/webmail/ and check the filter connection.

Roundcube
Sorrily Apple decided to use the old-fashioned, ugly SquirrelMail webmailer and not RoundCube.
RoundCube is much nicer and also the "managesieve" plugin available for it is much better than avelsieve in SquirrelMail.
Luckily you can install RoundCube on your SLS without harming the default installation.
To install RoundCube on SLS, see here

Enable managesieve plugin
ManageSieve plugin comes with RoundCube.
To enable it, edit file roundcube/config/main.inc.php:
$rcmail_config['plugins'] = array('managesieve');

Then edit file plugins/managesieve/lib/Net/Sieve.php:
- comment line var $supportedAuthMethods=.... (comment with //)
- uncomment line var $supportedAuthMethods=array( 'PLAIN' , 'Login' );

Set timezone
You will get timezone errors in the roundcube/logs/errors log file.
To fix this, add the following to
/etc/php.ini:
enable and change date.timezone to a value you find in the php doc
Example:
date.timezone = Europe/Berlin

Test roundcube
Now test roundcube by accessing http://<SLS_server_name>/roundcube/
Login as a user you like to change server side rules for
Click on "Settings" in the upper right corner, then on Filter.
If you see the page and no error occurs, you are sucessfully connected to the sieve backend of IMAP!
You now can create your rules.

The Sieve configuration file
The sieve config file is stored in dir
/private/var/spool/imap/dovecot/sieve-scripts/<GUID_OF_USER>/

The good thing is, that every rule managing application (Apple web rule management, SquirrelMail, RoundCube) you use, store its own file. So one app is not overwriting the others config file.
This is of importance if you enable the apple built-in crippled rule management and store the rules, there. This creates an own file "wiki_server_rules.sieve" in your sieve script dir and enables it by the link dovecot.sieve -> wiki_server_rules.sieve

To re-enable your SquirrelMail/RoundCube rules, simply delete the dovecot.sieve symbolic link (as root user) and add a link to your file:
sudo bash
cd /private/var/spool/imap/dovecot/sieve-scripts/<GUID_OF_USER>/
rm dovecot.sieve
ln -s roundcube.sieve dovecot.sieve

Then restart the Mail service.

Hope this helps.

7 comments:

Thinh said...

Thank you Robert.

It works perfectly. Now I can move to Snow leopard.

This is the on;y thing to hold me back.

Thanks again.

Lori said...

Hi Robert,

Thank you for the information; it was very helpful to me! During my initiate setup attempts, I only had CRAM-MD5 authentication enabled on the mail server (I always prefer NOT to transmit plain text passwords). Was it also your experience that only PLAIN authentication would work with Avelsieve? Any idea why this would be the case?

Atomic said...

Lori, it's the same for me. Only PLAIN auth mechanism works. I don't know why. But it isn't a problem for me, as the frontend is on the same machine as the backend. Therefore, traffic is only internal to SLS.

q3media said...

Hello Robert
Thanks a lot for helping me out!!!
The only thing I cannot get to work is sieve with roudcube.
Everything works fine but when I click on 'Filter' all I get is an empty page.
Any ideas?

Atomic said...

If you get a blank screen, it means the rule plugin cannot connect to your imap backend. Have you changed the authentication mechanism to PLAIN as explained in the article? Otherwise, you get exactly that blank screen.

Luis Rojas said...

While some people are reporting the sieve plugin gives a blank page when clicking on filter, i dont even see the filter link. All the configuration is done as it is supposed to... can anybody provide a link to the documentation on how to properly enable the managesieve plugin in roundcube?

luisfel said...

thanks....