article en anglais merci à
NetMoThe
documentation for setting up sieve on Mac OS X server is sparse, at best:
- Citation :
- To enable Sieve support:
1. Add the following entry in /etc/services/:
sieve 2000/tcp #Sieve mail filtering
2. Reload the mail service.
Right. This will
enable the service, but it doesn’t
configure it. This short article describes how to do both.
1. Create the Sieve DirectoryFor those without much experience, Apple’s documentation doesn’t mean much, plus its missing some important steps. The first step, which isn’t mentioned, is to create the sieve directory, where the sieve steps are to be located on your filesystem. You’ll be working in the Terminal application for this whole procedure. To create the sieve directory with the appropriate ownership in Leopard, do:
- Code:
-
sudo mkdir /usr/sieve
sudo chown _cyrus:mail /usr/sieve
2. Enable the Sieve ServiceThe next step is to open /etc/services with a text editor — I use ‘vi’, but Apple helps newbies out by shipping the pico text editor with Leopard. To load the services file into pico:
- Code:
-
sudo pico /etc/services
Use the arrow keys to scroll down, or, press Control-W, and type in ‘callbook’, followed by enter. There is already a service for port 2000 listed in Leopard’s services file: callbook. I have no idea what callbook is, so I replace it with sieve:
- Code:
-
sieve 2000/tcp #Sieve mail filtering
callbook 2000/udp # callbook
#callbook 2000/tcp # callbook
Save your changes by pressing Control-o, and exit with Control-x. Sieve will be enabled as soon as the mail service is restarted. Before you do that though, setup a mail administrator account.
3. Setup a Mail Administrator AccountIn order to install sieve scripts for other users, you need a mail administrator account. You should add a special account with a secure password for this task, but you could just add your own user account as a mail administrator. Supposing we have a special account named “mailadmin”, to enable it as a Cyrus mail administrator, open the /etc/imapd.conf file in your text editor, and change the first line:
- Code:
-
admins: cyrusimap, mailadmin
4. Restart the Mail ServiceYou can restart the mail services by using the Server Admin application, or by running this at the command line:
- Code:
-
sudo serveradmin stop mail
sudo serveradmin status mail
... ( it should indicate that the mail service is stopped ) ...
sudo serveradmin start mail
sudo serveradmin status mail
... ( it should now indicate that the mail service is running ) ...
You can tell if the sieve service is running by checking to see if the server is listening on TCP port 2000, by running this command:
- Code:
-
netstat -an | grep 2000
tcp4 0 0 *.2000 *.* LISTEN
tcp6 0 0 *.2000 *.* LISTEN
5. Add a Sieve ScriptNow all you need to do is add sieve scripts for users. Sieve scripts are text files. To add sieve scripts, you can use the sieveshell command, which is located in the obscure location, /usr/bin/cyrus/sieve/sieveshell. I suggest that you make life easier by symlinking it to your /usr/bin directory:
- Code:
-
sudo ln -s /usr/bin/cyrus/sieve/sieveshell /usr/bin/sieveshell
Apple’s Mail Administration manual has several example scripts. The most common is probably a vacation message, so I’ll use that example. Copy and paste the example vacation script into a text file (’pico vacation.msg’):
- Code:
-
#--------
# This is a sample script for vacation rules.
# Read the comments following the pound/hash to find out
# what the script is doing.
#---------
#
# Make sure the vacation extension is used.
require "vacation";
# Define the script as a vacation script
vacation
# Send the vacation response to any given sender only once every seven days
no matter how many messages are sent from him.
:days 7
#For every message sent to these addresses
:addresses ["bob@example.com", "robert.fakeuser@server.com"]
# Make a message with the following subject
:subject "Out of Office Reply"
# And make the body of the message the following
"I’m out of the office and will return on December 31. I won’t be able to
replay until 6 months after that. Love, Bob.";
# End of Script
Note that there are two addresses between the brackets on the “:addresses” line. Be sure to put any aliases that you have for your address in a comma-separated list, or they won’t get an automated reply.
Going with the example and supposing that I have a user named “bob”, I would then add this sieve script, which is saved to an arbitrarily-named text file, “vacation.msg”, by running the following on the command line:
- Code:
-
sieveshell --user=bob --authname=mailadmin localhost
This will get you into the interactive sieveshell. Type ‘help’ to see available commands. Assuming that your saved sieve script vacation.msg is in the current directory, install it for bob by running:
- Code:
-
put vacation.msg
Verify that its there by running list. The last step is to activate the script with the activate command:
- Code:
-
activate vacation.msg
list
That’s it. There will now be a directory, /usr/sieve/b/bob that contains bob’s sieve data, and you should get an automatic reply when you send an email to
bob@example.com.