- Products
- Purchase
Order Online Maintenance Renewal Resellers - Support
Helpdesk Online Documentation Web Forum - Our Clients
- About
About us Services Contact
From AfterLogic Wiki
Contents |
Introduction
Sieve is a special language which is used for configuring mail filters. Many popular mail servers either support Sieve out-of-box or can be used along with Sieve servers.
Starting from version 6.2, WebMail Pro (PHP) can be configured to use server-side Sieve filtering, that allows for using filters in WebMail Pro itself.
For this to work, MTA should have Sieve support enabled, and ManageSieve server needs to be installed in the system. It's available as part of our MailSuite Pro bundle, and it may be available as part of popular MTAs like Exim and Postfix. In case of MailSuite Pro, no configuration is required, ManageSieve configuration is performed as part of isntallation process. And if you run any other mail server software, you can download our ManageSieve solution and configure it to run along with your mail server.
In case if you already have ManageSieve server up and running along with your MTA you can skip to the last section where WebMail Pro configuration is explained. Otherwise, you'll need to configure ManageSieve support on your server first. Below, you'll find samples of configuration files for our MailSuite Pro bundle, but that should work with original Exim or other mail server in a similar way.
Configure ManageSieve server
ManageSieve server runs on localhost and listens to port 2000. It is strongly recommended to deny access to server from outside, that can be done by adjusting firewall policies.
Configuration file sample:
# /usr/mailsuite/etc/asieve.cfg # Enable logging [Sieve.Log] DisableLogging=false # Configuring 1st logger [Sieve.Log.Sink:MySink1] Destination=TextFile FileName=/var/log/asieve/Session_%Y-%b-%d.log Format=<%Channel%> %TimeStamp% [%Severity%] %RemoteIP%:%RemotePort% %Username% %Command%> %_% Asynchronous=false AutoFlush=true # Configuring server [Sieve.Server] #Host=0.0.0.0 #Port=2000 # Adding plugins Plugin=/usr/mailsuite/lib/manage_sieve/libfs_profile.so Plugin=/usr/mailsuite/lib/manage_sieve/libmysql_authenticator.so Plugin=/usr/mailsuite/lib/manage_sieve/libplain_authenticator.so #Plugin=/usr/mailsuite/lib/manage_sieve/libpam_authenticator.so # Supplying which authentication method is used by server Authenticator=MySQL # To use plain authentication, commend out the rest of lines related and uncomment the line below #Authenticator=Plain # Define user profile type Profile=FSProfile # Configuring profile management plugin [Sieve.Server.Profile.FSProfile] # Supply path to directory which contains filters, path should be relative to user directory ScriptDirectory=filters # User's homedir template HomeDirectory=/usr/mailsuite/data/%domain%/%local_part% # Configuring MySQL authentication [Sieve.Server.Authenticator.MySQL] # MySQL host:port or socket path Host=/usr/mailsuite/tmp/mysql.sock # DB name Database=exim # DB username User=root # DB password Password=mailbundle # The query used to authenticate ‘local_part’@’domain’ with ‘password’ password Query=SELECT distinct awm_accounts.mail_inc_login as login, DP1(awm_accounts.mail_inc_pass) as password, CONCAT('/usr/mailsuite/data/%domain%/%local_part%') as maildir FROM awm_accounts INNER JOIN awm_domains ON awm_accounts.id_domain = awm_domains.id_domain WHERE (awm_accounts.mail_inc_login = CONCAT('%local_part%', '@', '%domain%') OR awm_accounts.mail_inc_login = '%local_part%') AND awm_domains.name = '%domain%' AND awm_domains.is_internal = 1 AND DP1(awm_accounts.mail_inc_pass) = '%password%' ; # Configuring Plain authentication [Sieve.Server.Authenticator.Plain] # Single password for authentifying any user Password=mypasswd
Sieve server generates Sieve scripts and places them under filters subdirectory of user dir in Exim. When the script is made active, active_script file is added to the directory, and it contains active script name. It is possible to have multiple actions relying on multiple conditions in a single script.
The usual approach for starting Sieve server is as follows:
( /usr/mailsuite/bin/asieve_server --config=/usr/mailsuite/etc/asieve.cfg )&
Configure Exim
The configuration file adjusted is:
/etc/mailsuite/etc/exim.cnf
Setting up the router
In terms of Exim MTA, router is a driver which scans the message, runs filters for it and, based on filter execution results, determines which transport should be used to deliver the message.
userforward: driver = redirect allow_filter user = exim group = exim file = /usr/mailsuite/data/${domain}/${local_part}/${if exists{/usr/mailsuite/data/${domain}/${local_part}/filters/active_script}{filters/${readfile{/usr/mailsuite/data/${domain}/${local_part}/filters/active_script}{}}}{forward}} no_verify no_expn check_ancestor file_transport = local_delivery pipe_transport = address_pipe reply_transport = address_reply condition = ${if exists{/usr/mailsuite/data/${domain}/${local_part}/forward}{yes}{${if exists{/usr/mailsuite/data/${domain}/${local_part}/filters/active_script}{yes}{no}}}}
Setting up transport
Transport is a driver that transmits a copy of the message from Exim spool to a certain destination. Basically, Sieve filter returns a directory the message is moved to. In the directory, rule is supplied for filtering the value and converting it into Maildir-compliant format.
local_delivery: driver = appendfile check_string = "" delivery_date_add directory = /usr/mailsuite/data/${domain}/${local_part}/\ ${sg{${sg{/${address_file}}{/+}{.}}}{(?i)^.inbox}{}} directory_mode = 770 envelope_to_add group = exim maildir_format maildir_tag = ,S=$message_size message_prefix = "" message_suffix = "" mode = 0660
Install Sieve plugin for WebMail Pro
Download the plugin and extract it into data/plugins under WebMail directory. Then, modify config.php file, you should add the following key/value pairs into the array found there:
'plugins.webmail-sieve-filters' => true, 'plugins.webmail-sieve-filters.config.file' => 'sieve', 'plugins.webmail-sieve-filters.config.host' => '127.0.0.1', 'plugins.webmail-sieve-filters.config.port' => 2000
The plugin parameters stand for script's name on the server, host and port for accessing sieve server respectively.
Once this is done, you should be able to configure filter rules for your WebMail Pro account, check "Filters" tab in account settings. Note that this would only work for IMAP accounts. For POP3, WebMail Pro filters work on database level and do not rely on Sieve.
Last edit: 2011/11/22