[roundcube + managesieve] - Filters doesn't work i RoundCube

machine

New member
Joined
Dec 13, 2016
Messages
4
Hi,
My managesieve filters doesn't work

My config:
DirectAdmin v1.50.1
Custombuild 2.0.0 (rev: 1622)
Dovecot: 2.2.27 (c0f36b0) with Pidgeonhole SpamAssasin, SpamBlocker and DKIM
Exim 4.87
Debian 8.6

INSTALL:
Code:
cd /usr/local/directadmin/custombuild
./build set pigeonhole yes
./build dovecot
./build roundcube

/etc/dovecot/conf.d/90-sieve.conf
Code:
#Managesieve service (allows rules editing on client-side)
service managesieve-login {
  inet_listener sieve {
    port = 4190
  }
  service_count = 1
  process_min_avail = 4
  vsz_limit = 64M
}

service managesieve {
}

protocol sieve {
  managesieve_max_line_length = 65536
  managesieve_implementation_string = Dovecot Pigeonhole
  managesieve_max_compile_errors = 5
  managesieve_logout_format = bytes=%i/%o
  log_path = /var/log/dovecot-sieve-errors.log
  info_log_path = /var/log/dovecot-sieve.log
}

plugin {
   sieve = file:~/sieve;active=~/.dovecot.sieve
   sieve_default = /var/lib/dovecot/sieve/default.sieve
   sieve_global = /var/lib/dovecot/sieve/global/

/etc/dovecot/conf/protocols.conf
Code:
protocols = imap pop3 lmtp sieve

/etc/exim.conf
Code:
virtual_user:
  driver = accept
  condition = ${perl{save_virtual_user}}
  domains = lsearch;/etc/virtual/domainowners
  group = mail
  retry_use_local_part
  transport = dovecot_lmtp_udp

#COMMENT#64:
address_reply:
  driver = autoreply

dovecot_lmtp_udp:
  driver = lmtp
  socket = /var/run/dovecot/lmtp
  #maximum number of deliveries per batch, default 1
  batch_max = 200
  delivery_date_add
  envelope_to_add
  return_path_add
  user = mail

/var/www/html/roundcube/plugins/managesieve/config.inc.php
Code:
$config['managesieve_port'] = 4190;
$config['managesieve_host'] = 'localhost';

/var/www/html/roundcube/config/config.inc.php
Code:
$config['plugins'] = array(
    'managesieve',
    'password',
    'archive',
    'zipdownload',
);

OK let TEST:

netstat -ntlp | grep '4190'
Code:
tcp        0      0 0.0.0.0:4190            0.0.0.0:*               LISTEN      2203/managesieve-lo

root@ds:/home/netcity# ls -la
Code:
razem 48
drwx--x---  8 netcity access  4096 gru 10 22:06 .
drwx--x--x  9 root    root    4096 gru 12 16:53 ..
drwx--x--x  3 netcity netcity 4096 gru 10 17:52 .appdata
-rw-r--r--  1 netcity netcity  220 lis 13  2014 .bash_logout
-rw-r--r--  1 netcity netcity 3515 lis 13  2014 .bashrc
drwx--x--x  3 netcity netcity 4096 gru 10 17:40 domains
lrwxrwxrwx  1 netcity netcity   23 gru 10 22:06 .dovecot.sieve -> sieve/managesieve.sieve
drwxrwx---  3 netcity mail    4096 gru 10 17:40 imap
drwxrwx--- 10 netcity mail    4096 gru 14 21:22 Maildir
drwxrwx---  2 netcity apache  4096 gru 14 00:10 .php
-rw-r--r--  1 netcity netcity  675 lis 13  2014 .profile
lrwxrwxrwx  1 netcity netcity   35 gru 10 17:40 public_html -> ./domains/netcity.kl.pl/public_html
-rw-r-----  1 netcity mail      34 gru 10 17:40 .shadow
drwx------  3 netcity netcity 4096 gru 12 16:38 sieve

root@ds:/home/netcity# cat sieve/managesieve.sieve
Code:
require ["fileinto"];
# rule:[@ds.pl]
if header :contains "subject" "testx"
{
        fileinto "ds";
}

My managesieve filters doesn't work
PLEASE HELP.
 
Hello,

And why do you think it does not work? How did you test it to make sure it does not work?

Did you check mail and dovecot logs?
 
help us ! :)

Hi, Of course...

I do filters roundcube teeth to throw a message from the email address [email protected] to the "vf"
Unfortunately moves me these messages to the directory

http://netcity.kl.pl/roundcube.png

Code:
razem 48
drwx--x---  8 netcity access  4096 gru 10 22:06 .
drwx--x--x  9 root    root    4096 gru 12 16:53 ..
drwx--x--x  3 netcity netcity 4096 gru 10 17:52 .appdata
-rw-r--r--  1 netcity netcity  220 lis 13  2014 .bash_logout
-rw-r--r--  1 netcity netcity 3515 lis 13  2014 .bashrc
drwx--x--x  3 netcity netcity 4096 gru 10 17:40 domains
lrwxrwxrwx  1 netcity netcity   23 gru 10 22:06 .dovecot.sieve -> sieve/managesieve.sieve
drwxrwx---  3 netcity mail    4096 gru 10 17:40 imap
drwxrwx--- 10 netcity mail    4096 gru 15 09:09 Maildir
drwxrwx---  2 netcity apache  4096 gru 15 00:10 .php
-rw-r--r--  1 netcity netcity  675 lis 13  2014 .profile
lrwxrwxrwx  1 netcity netcity   35 gru 10 17:40 public_html -> ./domains/netcity.kl.pl/public_html
-rw-r-----  1 netcity mail      34 gru 10 17:40 .shadow
drwx------  3 netcity netcity 4096 gru 12 16:38 sieve

root@kl:/home/netcity# cat .dovecot.sieve
Code:
require ["fileinto"];
# rule:[@vf.pl]
if header :contains "from" "[email protected]"
{
        fileinto "vf";
}

I send a message from [email protected] to roundcube and the message gets to the root of the "INDEX"

No errors in logs:
Code:
-rw------- 1 root     root           1 gru 15 09:22 dovecot-lmtp-errors.log
-rw------- 1 root     root           0 gru 13 21:23 dovecot-lmtp.log
-rw-rw---- 1 root     root           0 gru 13 20:34 dovecot-sieve-errors.log
-rw-rw---- 1 root     root           0 gru 13 20:34 dovecot-sieve.log

In EXIM logs:
2016-12-15 09:21:28 1cHRI8-0008Cm-Td <= [email protected] H=vf.net.pl [81.6.133.3] P=esmtps X=TLSv1.2:DHE-RSA-AES128-SHA:128 CV=no S=938 [email protected] T="test" from <[email protected]> for [email protected]
2016-12-15 09:21:29 1cHRI8-0008Cm-Td => netcity <[email protected]> F=<[email protected]> R=localuser T=local_delivery S=1039
 
OK, I see. If I recall correctly, the sieve rules in the implementation of Directadmin developers work only for virtual addresses. They do not work for system accounts (which exist by default after user creation), i.e. for mail boxes username@hostname or username@domain, where username is a login into Directadmin. You need to create a virtual email box, i.e. additional email account the storage of which will be located under /imap/ folder of your account, i.e. /home/netcity/imap/netcity.kl.pl/
 
yea!

Hello, thank you you're right.

Assuming a sub domain eg [email protected] filters are working properly and are guided post office where needed.

root@kl:/home/netcity/imap/netcity.kl.pl/test# ls -la
Code:
razem 20
drwxrwx--- 4 netcity mail 4096 gru 15 21:24 .
drwxrwx--- 3 netcity mail 4096 gru 15 21:22 ..
lrwxrwxrwx 1 netcity mail   23 gru 15 21:21 .dovecot.sieve -> sieve/managesieve.sieve
-rw------- 1 netcity mail  250 gru 15 21:24 .dovecot.svbin
drwx------ 9 netcity mail 4096 gru 15 21:23 Maildir
drwx------ 3 netcity mail 4096 gru 15 21:23 sieve

root@kl:/home/netcity/imap/netcity.kl.pl/test# cat .dovecot.sieve
Code:
require ["fileinto"];
# rule:[@vf.pl]
if header :contains "from" "@vf.pl"
{
        fileinto "INBOX.spam";
}

But tell me if the main account [email protected] we are also able to set the sieve it work?

root@kl:/home/netcity# ls -la
Code:
razem 48
drwx--x---  8 netcity access  4096 gru 15 21:29 .
drwx--x--x  8 root    root    4096 gru 15 21:18 ..
drwx--x--x  3 netcity netcity 4096 gru 10 17:52 .appdata
-rw-r--r--  1 netcity netcity  220 lis 13  2014 .bash_logout
-rw-r--r--  1 netcity netcity 3515 lis 13  2014 .bashrc
drwx--x--x  3 netcity netcity 4096 gru 10 17:40 domains
lrwxrwxrwx  1 netcity netcity   23 gru 10 22:06 .dovecot.sieve -> sieve/managesieve.sieve
drwxrwx---  3 netcity mail    4096 gru 10 17:40 imap
drwxrwx--- 10 netcity mail    4096 gru 15 13:28 Maildir
drwxrwx---  2 netcity apache  4096 gru 15 00:10 .php
-rw-r--r--  1 netcity netcity  675 lis 13  2014 .profile
lrwxrwxrwx  1 netcity netcity   35 gru 10 17:40 public_html -> ./domains/netcity.kl.pl/public_html
-rw-r-----  1 netcity mail      34 gru 10 17:40 .shadow
drwx------  3 netcity netcity 4096 gru 15 09:21 sieve

root@kl:/home/netcity# cat .dovecot.sieve
Code:
require ["fileinto"];
# rule:[@vf.pl]
if header :contains "from" "@vf.pl"
{
        fileinto "INBOX.spam";
}


At the moment only works for sub-domain?

Thank you for your help.
 
It has nothing to do with subdomains at all. You should distinguish local (or system) and virtual users. Emails for them are delivered differently in Exim.

1. For virtual users:

Code:
virtual_user:
  driver = accept
  condition = ${if exists{/etc/virtual/${domain}/passwd}{1}{0}}
  condition = ${lookup{$local_part}lsearch{/etc/virtual/${domain}/aliases}{0}{1}}
  condition = ${perl{save_virtual_user}}
  domains = lsearch;/etc/virtual/domainowners
  group = mail
  retry_use_local_part
  transport = dovecot_lmtp_udp

emails are delivered via dovecot_lmtp_udp transport (and sieve rules work here).

2. For local (or system) users the transport local_delivery is used (no sieve rules work here):

Code:
localuser:
  driver = accept
  check_local_user
  condition = "${if eq {$domain} {$primary_hostname} {yes} {no}}"
  transport = local_delivery


And sieve rules with filtering work on Dovecot side only.

Thus it's due to how exim is configured to deliver emails for local and virtual users. If you don't like it you might want to forward emails for local (system) users to a virtual mail box using /home/<username>/.forward and then filter them with sieve.
 
Now I understand how it works, just tell me whether the localuser how I use dovecot from the sieve?

Code:
localuser:
  driver = accept
  check_local_user
  condition = "${if eq {$domain} {$primary_hostname} {yes} {no}}"
  transport = local_delivery

I see the same change local_delivery dovecot_lmtp_udp to me does not help because it is pre-define the home directory.

Code:
local_delivery:
  driver = appendfile
  delivery_date_add
  envelope_to_add
  directory = /home/$local_part/Maildir/
  directory_mode = 770
  create_directory = true
  maildir_format
  group = mail
  mode = 0660
  return_path_add
  user = ${local_part}


Code:
dovecot_lmtp_udp:
  driver = lmtp
  socket = /var/run/dovecot/lmtp
  #maximum number of deliveries per batch, default 1
  batch_max = 200
  delivery_date_add
  envelope_to_add
  return_path_add
  user = mail

Sorry for the stupid question but unfortunately exim for me is black magic .. unless you have any solution for localuser so teeth began to function sieve?
 
I won't guide you on how to modify exim, I don't need it for myself, and it never has been requested by my clients... Probably somebody else has a guide and will share it.

If you don't like how it works by default you might consider forwarding emails for local (system) users to a virtual mail box using /home/<username>/.forward and then filter them with sieve, or hire somebody (including me) to re-configure exim.
 
Back
Top