• Snow Leopard Sieve Rules


    How to edit _sieve_ rules in Snow Leopard by hand. This is not really recommended especially because it seems that SL server does not utilize all the sieve rules and the ones that it does utilize are in a slightly different format than exists in [Sieve documentation][1].
    A couple of sources later and a couple of quick lines of code helps to figure out what file to edit.
    > `u=”username”; dscl /Search read Users/$u GeneratedUID | awk {‘printf “/Library/EmailRules/sievescripts/”$2″.sieven”‘} | xargs -n1 -p sudo cat`
    > `u=”username”; dscl /Search read Users/$u GeneratedUID | awk {‘printf “/Library/EmailRules/sievescripts/”$2”.sieven”‘} | xargs -n1 -p sudo pico`
    Edit the command to make _u_ equal to the _username_ of the person and you can look at and edit the sieve files. I also don’t know why but I get the following error.
    > Received SIGHUP or SIGTERM
    All you have to do is simply copy the command and it will work. Not sure why it doesn’t work the first time.
    I’m quite certain if you go ahead and try to re-edit using the GUI your files might get screwed up. YMMV.
    Some say running the following command helps. Also, see **Update** below. Again, YMMV.
    > `sudo /usr/bin/wiki_sieve_manager`
    Finally a real solution to the above. Simply make sure you use the URL ****. Even if the website is not set up to use port 443 in Server Admin it seems you must use **https**.
    I discovered another secret. In order for the new rules to transfer you will need to add a new rule via the wiki, or at least go to the wiki and press the add rule button. This way the new rule is copied over to `/var/spool/imap/dovecot/sieve-scripts/%u`.

  • Server-Side Email Filtering With Sieve


    Another post for the peripheral brain.
    When I first set up my own server lo these years ago, I never really thought about email message filtering. After all, I had rules in that would send my incoming message to wherever I wanted them. Besides, I was much more concerned with eliminating spam.
    Well, that was then and spam seems under control. I was prompted to look at server-side message filtering mostly to help out my mother, who seems determined to have every single store, travel and other consumer site that will happily take your email address and send you messages daily — or more often, have a more controllable experience on her iPhone. When we originally set up her iPhone she told me she didn’t want to use it for email. Silly me, I listened and set her up with a POP account. Well now she wants email. What’s a good son to do. 😉
    I changed her POP account to IMAP, copied over all her messages to her new IMAP folders and thought I’d need to solve her impending problem of 100 or so messages every other day choking her inbox.
    After a bit of Googling I found Sieve. I’d actually heard of it before but never really thought about it. The Apple Discussion Forum had a nice start and pointed me on to sources I used to set it up.
    Here are the salient points. From the terminal…

    1. Add the following lines to /etc/services
      sudo pico /etc/services

      Insert the following lines.

      callbook 2000/udp # callbook
      callbook 2000/tcp # callbook
      + sieve 2000/udp # sieve mail filtering
      + sieve 2000/tcp # sieve mail filtering

      You can check to see if it’s running by running

      netstat -an | grep 2000

      with results

      tcp4 0 0 *.2000 *.* LISTEN
      tcp6 0 0 *.2000 *.* LISTEN
    2. Create /usr/sieve
      sudo mkdir /usr/sieve
      sudo chown _cyrus:mail /usr/sieve
    3. Restart mail services
      sudo serveradmin stop mail
      [ some stuff ]
      sudo serveradmin start mail
      [ some stuff ]
    4. Since I’m using OS X Server and SquirrelMail is already running, next was installing and configuring avelsieve.

    I really did try installing the latest development version — 1.9.9 alpha. That should have been a clue. After spending way too much time with it I installed the stable version – avelsieve 1.0.1. Once copied into /usr/share/squirrelmail/plugins run sudo perl /etc/squirrelmail/config/ and activate the plugin.
    Then it’s back to the terminal. These instructions are from AFP548.

        cd /usr/share/squirrelmail/plugins/avelsieve
        sudo cp config-sample.php config.php

    Now set the correct authentication matching SquirrelMail.
    Edit /etc/squirrelmail/plugins/avelsieve/config.php and change:

    $preferred_mech = "PLAIN";


    $preferred_mech = "CRAM-MD5";

    You should be running SquirrelMail with CRAM-MD5 authentication anyway.
    Finally, edit the /etc/squirrelmail/plugins/avelsieve/lib/sieve-php.lib.php file.
    Find the line:

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

    and change it to :

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

    This fixes an error in the script allowing you to save your changes to the filters. Now go login to webmail and click on the Filter link to start creating your Sieve filters.