Managesieve filtres

Hi guys! I have a problem in roundcube there are managivesive filtres, it is enabled and configured, but if you make any filter in it (I need letters from a specific e-mail to be filtered into a specific created folder) it does not work, the letters arrive in the Inbox anyway, but not in the created folder specified in the filter, how to fix this and where to look? Thank you!

Have you tried searching for troubleshooting managesieve?

YES! but there is no effect.

Hi @LDM1983,

Could you please show the output of these commands?

Note: Replace YourUser, YourDomain and MailAccount by the actual data.

grep sieve /etc/roundcube/config.inc.php
grep -r 'mail.*sieve' /etc/dovecot/
lsof -Pn +c0 -i:4190 -sTCP:LISTEN
cat /home/YourUser/mail/YourDomain/MailAccount/sieve/managesieve.sieve
ls -la /home/YourUser/mail/YourDomain/MailAccount/
1 Like

1 updates could not be installed automatically. For more details,
see /var/log/unattended-upgrades/unattended-upgrades.log
Last login: Wed Feb 21 11:19:51 2024 from 37.233.18.218
root@hostname:~# grep sieve /etc/roundcube/config.inc.php
$config["plugins"] = ["archive", "password", "newmail_notifier", "zipdownload", "managesieve"];
root@hostname:~# grep -r 'mail.*sieve' /etc/dovecot/
/etc/dovecot/sieve/90-sieve.conf:  sieve = file:~/mail/%d/%n/sieve;active=~/mail/%d/%n/dovecot.sieve
/etc/dovecot/conf.d/90-sieve.conf:  sieve = file:~/mail/%d/%n/sieve;active=~/mail/%d/%n/dovecot.sieve
/etc/dovecot/conf.d/20-imap.conf:  mail_plugins = quota imap_quota imap_sieve
/etc/dovecot/conf.d/15-lda.conf:  mail_plugins = $mail_plugins quota sieve
root@hostname:~# lsof -Pn +c0 -i:4190 -sTCP:LISTEN
COMMAND    PID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
dovecot 511089 root   15u  IPv4 1569989      0t0  TCP *:4190 (LISTEN)
dovecot 511089 root   16u  IPv6 1569990      0t0  TCP *:4190 (LISTEN)
root@hostname:~# cat /home/bookshub/mail/bookshub.ru/a.abramychev/sieve/managesieve.sieve
# rule:[Ozon]
if allof (header :contains "from" "[email protected]")
{
        discard;
}
# rule:[Yandex]
if allof (header :contains "from" "[email protected]")
{
        discard;
}
root@hostname:~# ls -la /home/bookshub/mail/bookshub.ru/a.abramychev/
total 6564
drwx------ 11 bookshub mail    4096 Apr  3 10:41 .
drwxrwx--- 19 bookshub mail    4096 Apr  1 09:45 ..
drwx------  5 bookshub mail    4096 Feb 20 14:18 .Archive
drwx------  5 bookshub mail    4096 Apr  1 17:18 .Drafts
drwx------  5 bookshub mail    4096 Apr  3 10:16 .Sent
drwx------  5 bookshub mail    4096 Mar  8 13:03 .Spam
drwx------  5 bookshub mail    4096 Apr  3 08:35 .Trash
drwxr-x---  2 bookshub mail  454656 Apr  3 10:40 cur
-rw-------  1 bookshub mail      13 Feb 21 12:04 dovecot-keywords
-rw-------  1 bookshub mail  344656 Apr  3 10:40 dovecot-uidlist
-rw-------  1 bookshub mail       8 Feb 13 11:21 dovecot-uidvalidity
-r--r--r--  1 bookshub mail       0 Feb 13 11:21 dovecot-uidvalidity.65cb26a6
-rw-------  1 bookshub mail  126184 Apr  3 10:06 dovecot.index
-rw-------  1 bookshub mail 5593964 Apr  3 10:40 dovecot.index.cache
-rw-------  1 bookshub mail   31480 Apr  3 10:41 dovecot.index.log
-rw-------  1 bookshub mail   32792 Apr  1 19:12 dovecot.index.log.2
-rw-------  1 bookshub mail     888 Apr  1 15:56 dovecot.list.index
-rw-------  1 bookshub mail    4816 Apr  1 18:48 dovecot.list.index.log
-rw-------  1 bookshub mail     120 Feb 13 11:21 dovecot.mailbox.log
lrwxrwxrwx  1 bookshub mail      23 Apr  3 10:18 dovecot.sieve -> sieve/managesieve.sieve
-rw-rw----  1 bookshub mail    2322 Apr  3 10:40 maildirsize
drwxr-x---  2 bookshub mail   36864 Apr  3 10:40 new
drwx------  3 bookshub mail    4096 Apr  3 10:34 sieve
-rw-------  1 bookshub mail      36 Feb 13 11:21 subscriptions
drwxr-x---  2 bookshub mail    4096 Apr  3 10:40 tmp
root@hostname:~#

I see no issues.

Check dovecot log to see if those messages are being discarded:

grep -r 'lda.*sieve.*discard' /var/log/dovecot.log

Also, those messages arrive marked as spam?

Could you please add a new sieve rule to discard a message from a well known email address that you control or with an specific subject… just to test whether the mail is discarded?

1 Like

This command doesn’t work for me.

root@hostname:~# ^C
root@hostname:~# grep -r 'lda.*sieve.*discard' /var/log/dovecot.log
root@hostname:~# grep -r 'lda.*sieve.*discard' /var/log/dovecot.log
root@hostname:~# grep -r 'lda.*sieve.*discard' /var/log/dovecot.log
root@hostname:~#
root@hostname:~# root@hostname:~# ^C
-bash: root@hostname:~#: command not found
root@hostname:~# root@hostname:~# grep -r 'lda.*sieve.*discard' /var/log/dovecot.log
-bash: root@hostname:~#: command not found
root@hostname:~# root@hostname:~# grep -r 'lda.*sieve.*discard' /var/log/dovecot.log
-bash: root@hostname:~#: command not found
root@hostname:~# root@hostname:~# grep -r 'lda.*sieve.*discard' /var/log/dovecot.log
-bash: root@hostname:~#: command not found
root@hostname:~# root@hostname:~#
-bash: root@hostname:~#: command not found
root@hostname:~#
root@hostname:~# root@hostname:~# ^C
-bash: root@hostname:~#: command not found
root@hostname:~# root@hostname:~# grep -r 'lda.*sieve.*discard' /var/log/dovecot.log
-bash: root@hostname:~#: command not found
root@hostname:~# root@hostname:~# grep -r 'lda.*sieve.*discard' /var/log/dovecot.log
-bash: root@hostname:~#: command not found
root@hostname:~# root@hostname:~# grep -r 'lda.*sieve.*discard' /var/log/dovecot.log
-bash: root@hostname:~#: command not found
root@hostname:~# root@hostname:~#
-bash: root@hostname:~#: command not found
root@hostname:~# grep -r 'lda.*sieve.*discard' /var/log/dovecot.log
root@hostname:~# grep -r 'lda.*sieve.*discard' /var/log/dovecot.log
root@hostname:~#

NO.

I’ll check it now.

1 Like

Executing the command once is enough :wink:

When you check it, review manually /var/log/dovecot.log file to see any errors.

1 Like

I did, but, unfortunately, mail is not rejected even from a controlled address.

So, there is nothing in dovecot.log, the message arrives to your inbox and the message is not marked as spam (did you check the headers of the message to be sure?).

Apr 03 11:19:33 managesieve-login: Info: Login: user=<[email protected]>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=2231257, secured, session=<3Lfy4SwVPqJ/AAAB>
Apr 03 11:19:33 managesieve([email protected])<2231257><3Lfy4SwVPqJ/AAAB>: Debug: Added userdb setting: plugin/quota_rule=*:storage=0M
Apr 03 11:19:33 managesieve([email protected])<2231257><3Lfy4SwVPqJ/AAAB>: Debug: Effective uid=1002, gid=8, home=/home/bookshub
Apr 03 11:19:33 managesieve([email protected])<2231257><3Lfy4SwVPqJ/AAAB>: Debug: Namespace : type=private, prefix=, sep=/, inbox=yes, hidden=no, list=yes, subscriptions=yes location=maildir:/home/bookshub/mail/bookshub.ru/a.abramychev
Apr 03 11:19:33 managesieve([email protected])<2231257><3Lfy4SwVPqJ/AAAB>: Debug: maildir++: root=/home/bookshub/mail/bookshub.ru/a.abramychev, index=, indexpvt=, control=, inbox=/home/bookshub/mail/bookshub.ru/a.abramychev, alt=
Apr 03 11:19:33 managesieve([email protected])<2231257><3Lfy4SwVPqJ/AAAB>: Debug: sieve: Pigeonhole version 0.5.16 (09c29328) initializing
Apr 03 11:19:33 managesieve([email protected])<2231257><3Lfy4SwVPqJ/AAAB>: Debug: sieve: include: sieve_global is not set; it is currently not possible to include `:global' scripts.
Apr 03 11:19:33 managesieve([email protected])<2231257><3Lfy4SwVPqJ/AAAB>: Debug: sieve: Sieve imapsieve plugin for Pigeonhole version 0.5.16 (09c29328) loaded
Apr 03 11:19:33 managesieve([email protected])<2231257><3Lfy4SwVPqJ/AAAB>: Debug: sieve: Sieve Extprograms plugin for Pigeonhole version 0.5.16 (09c29328) loaded
Apr 03 11:19:33 managesieve([email protected])<2231257><3Lfy4SwVPqJ/AAAB>: Debug: sieve: file storage: Using active Sieve script path: /home/bookshub/mail/bookshub.ru/a.abramychev/dovecot.sieve
Apr 03 11:19:33 managesieve([email protected])<2231257><3Lfy4SwVPqJ/AAAB>: Debug: sieve: file storage: Using script storage path: /home/bookshub/mail/bookshub.ru/a.abramychev/sieve
Apr 03 11:19:33 managesieve([email protected])<2231257><3Lfy4SwVPqJ/AAAB>: Debug: sieve: file storage: Using permissions from /home/bookshub/mail/bookshub.ru/a.abramychev/sieve: mode=0700 gid=-1
Apr 03 11:19:33 managesieve([email protected])<2231257><3Lfy4SwVPqJ/AAAB>: Debug: sieve: file storage: Relative path to sieve storage in active link: sieve/
Apr 03 11:19:33 managesieve([email protected])<2231257><3Lfy4SwVPqJ/AAAB>: Debug: sieve: file storage: sync: Synchronization active
Apr 03 11:19:33 managesieve([email protected])<2231257><3Lfy4SwVPqJ/AAAB>: Debug: sieve: file storage: script `managesieve': Opened script `managesieve' from `/home/bookshub/mail/bookshub.ru/a.abramychev/sieve/managesieve.sieve'
Apr 03 11:19:33 managesieve([email protected])<2231257><3Lfy4SwVPqJ/AAAB>: Debug: sieve: file storage: script `managesieve': Opened script for reading
Apr 03 11:19:33 managesieve([email protected])<2231257><3Lfy4SwVPqJ/AAAB>: Debug: sieve: file storage: script `managesieve': Closed script
Apr 03 11:19:33 managesieve([email protected])<2231257><3Lfy4SwVPqJ/AAAB>: Info: Disconnected: Logged out bytes=56/841
Apr 03 11:19:35 managesieve-login: Info: Login: user=<[email protected]>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=2231259, secured, session=<IS0J4iwVRKJ/AAAB>
Apr 03 11:19:35 managesieve([email protected])<2231259><IS0J4iwVRKJ/AAAB>: Debug: Added userdb setting: plugin/quota_rule=*:storage=0M
Apr 03 11:19:35 managesieve([email protected])<2231259><IS0J4iwVRKJ/AAAB>: Debug: Effective uid=1002, gid=8, home=/home/bookshub
Apr 03 11:19:35 managesieve([email protected])<2231259><IS0J4iwVRKJ/AAAB>: Debug: Namespace : type=private, prefix=, sep=/, inbox=yes, hidden=no, list=yes, subscriptions=yes location=maildir:/home/bookshub/mail/bookshub.ru/a.abramychev
Apr 03 11:19:35 managesieve([email protected])<2231259><IS0J4iwVRKJ/AAAB>: Debug: maildir++: root=/home/bookshub/mail/bookshub.ru/a.abramychev, index=, indexpvt=, control=, inbox=/home/bookshub/mail/bookshub.ru/a.abramychev, alt=
Apr 03 11:19:35 managesieve([email protected])<2231259><IS0J4iwVRKJ/AAAB>: Debug: sieve: Pigeonhole version 0.5.16 (09c29328) initializing
Apr 03 11:19:35 managesieve([email protected])<2231259><IS0J4iwVRKJ/AAAB>: Debug: sieve: include: sieve_global is not set; it is currently not possible to include `:global' scripts.
Apr 03 11:19:35 managesieve([email protected])<2231259><IS0J4iwVRKJ/AAAB>: Debug: sieve: Sieve imapsieve plugin for Pigeonhole version 0.5.16 (09c29328) loaded
Apr 03 11:19:35 managesieve([email protected])<2231259><IS0J4iwVRKJ/AAAB>: Debug: sieve: Sieve Extprograms plugin for Pigeonhole version 0.5.16 (09c29328) loaded
Apr 03 11:19:35 managesieve([email protected])<2231259><IS0J4iwVRKJ/AAAB>: Debug: sieve: file storage: Using active Sieve script path: /home/bookshub/mail/bookshub.ru/a.abramychev/dovecot.sieve
Apr 03 11:19:35 managesieve([email protected])<2231259><IS0J4iwVRKJ/AAAB>: Debug: sieve: file storage: Using script storage path: /home/bookshub/mail/bookshub.ru/a.abramychev/sieve
Apr 03 11:19:35 managesieve([email protected])<2231259><IS0J4iwVRKJ/AAAB>: Debug: sieve: file storage: Using permissions from /home/bookshub/mail/bookshub.ru/a.abramychev/sieve: mode=0700 gid=-1
Apr 03 11:19:35 managesieve([email protected])<2231259><IS0J4iwVRKJ/AAAB>: Debug: sieve: file storage: Relative path to sieve storage in active link: sieve/
Apr 03 11:19:35 managesieve([email protected])<2231259><IS0J4iwVRKJ/AAAB>: Debug: sieve: file storage: sync: Synchronization active
Apr 03 11:19:35 managesieve([email protected])<2231259><IS0J4iwVRKJ/AAAB>: Debug: sieve: file storage: script `managesieve': Opened script `managesieve' from `/home/bookshub/mail/bookshub.ru/a.abramychev/sieve/managesieve.sieve'
Apr 03 11:19:35 managesieve([email protected])<2231259><IS0J4iwVRKJ/AAAB>: Debug: sieve: file storage: script `managesieve': Opened script for reading
Apr 03 11:19:35 managesieve([email protected])<2231259><IS0J4iwVRKJ/AAAB>: Debug: sieve: file storage: script `managesieve': Closed script
Apr 03 11:19:35 imap-login: Info: Login: user=<[email protected]>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=2231261, secured, session=<Ha0J4iwVhMh/AAAB>
Apr 03 11:19:35 imap([email protected])<2231261><Ha0J4iwVhMh/AAAB>: Debug: Loading modules from directory: /usr/lib/dovecot/modules
Apr 03 11:19:35 imap([email protected])<2231261><Ha0J4iwVhMh/AAAB>: Debug: Module loaded: /usr/lib/dovecot/modules/lib10_quota_plugin.so
Apr 03 11:19:35 imap([email protected])<2231261><Ha0J4iwVhMh/AAAB>: Debug: Module loaded: /usr/lib/dovecot/modules/lib11_imap_quota_plugin.so
Apr 03 11:19:35 imap([email protected])<2231261><Ha0J4iwVhMh/AAAB>: Debug: Module loaded: /usr/lib/dovecot/modules/lib95_imap_sieve_plugin.so
Apr 03 11:19:35 imap([email protected])<2231261><Ha0J4iwVhMh/AAAB>: Debug: Added userdb setting: plugin/quota_rule=*:storage=0M
Apr 03 11:19:35 imap([email protected])<2231261><Ha0J4iwVhMh/AAAB>: Debug: Effective uid=1002, gid=8, home=/home/bookshub
Apr 03 11:19:35 imap([email protected])<2231261><Ha0J4iwVhMh/AAAB>: Debug: Quota root: name=User quota backend=maildir args=
Apr 03 11:19:35 imap([email protected])<2231261><Ha0J4iwVhMh/AAAB>: Debug: Quota rule: root=User quota mailbox=* bytes=0 messages=0
Apr 03 11:19:35 imap([email protected])<2231261><Ha0J4iwVhMh/AAAB>: Debug: Quota grace: root=User quota bytes=0 (10%)
Apr 03 11:19:35 imap([email protected])<2231261><Ha0J4iwVhMh/AAAB>: Debug: Namespace : type=private, prefix=, sep=/, inbox=yes, hidden=no, list=yes, subscriptions=yes location=maildir:/home/bookshub/mail/bookshub.ru/a.abramychev
Apr 03 11:19:35 imap([email protected])<2231261><Ha0J4iwVhMh/AAAB>: Debug: maildir++: root=/home/bookshub/mail/bookshub.ru/a.abramychev, index=, indexpvt=, control=, inbox=/home/bookshub/mail/bookshub.ru/a.abramychev, alt=
Apr 03 11:19:35 imap([email protected])<2231261><Ha0J4iwVhMh/AAAB>: Debug: quota: quota_over_flag check: quota_over_script unset - skipping
Apr 03 11:19:35 imap([email protected])<2231261><Ha0J4iwVhMh/AAAB>: Info: Disconnected: Logged out in=201 out=772 deleted=0 expunged=0 trashed=0 hdr_count=0 hdr_bytes=0 body_count=0 body_bytes=0
Apr 03 11:19:35 managesieve([email protected])<2231259><IS0J4iwVRKJ/AAAB>: Info: Disconnected: Logged out bytes=56/841
Apr 03 11:19:36 auth: Info: missing passwd file: /etc/exim4/domains//passwd
Apr 03 11:19:37 auth: Info: missing passwd file: /etc/exim4/domains//passwd
Apr 03 11:19:38 auth: Info: missing passwd file: /etc/exim4/domains//passwd
Apr 03 11:19:41 managesieve-login: Info: Login: user=<[email protected]>, method=PLAIN, rip=127.0.0.1, lip=127.0.0.1, mpid=2231265, secured, session=<l4pq4iwVCIB/AAAB>
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Debug: Added userdb setting: plugin/quota_rule=*:storage=0M
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Debug: Effective uid=1002, gid=8, home=/home/bookshub
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Debug: Namespace : type=private, prefix=, sep=/, inbox=yes, hidden=no, list=yes, subscriptions=yes location=maildir:/home/bookshub/mail/bookshub.ru/a.abramychev
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Debug: maildir++: root=/home/bookshub/mail/bookshub.ru/a.abramychev, index=, indexpvt=, control=, inbox=/home/bookshub/mail/bookshub.ru/a.abramychev, alt=
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Debug: sieve: Pigeonhole version 0.5.16 (09c29328) initializing
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Debug: sieve: include: sieve_global is not set; it is currently not possible to include `:global' scripts.
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Debug: sieve: Sieve imapsieve plugin for Pigeonhole version 0.5.16 (09c29328) loaded
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Debug: sieve: Sieve Extprograms plugin for Pigeonhole version 0.5.16 (09c29328) loaded
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Debug: sieve: file storage: Using active Sieve script path: /home/bookshub/mail/bookshub.ru/a.abramychev/dovecot.sieve
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Debug: sieve: file storage: Using script storage path: /home/bookshub/mail/bookshub.ru/a.abramychev/sieve
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Debug: sieve: file storage: Using permissions from /home/bookshub/mail/bookshub.ru/a.abramychev/sieve: mode=0700 gid=-1
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Debug: sieve: file storage: Relative path to sieve storage in active link: sieve/
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Debug: sieve: file storage: sync: Synchronization active
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Debug: sieve: file storage: script `managesieve': Opened script `managesieve' from `/home/bookshub/mail/bookshub.ru/a.abramychev/sieve/managesieve.sieve'
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Debug: sieve: file storage: script `managesieve': Opened script for reading
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Debug: sieve: file storage: script `managesieve': Closed script
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Debug: sieve: file storage: script `managesieve': save: Started saving script
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Debug: sieve: file storage: Using Sieve script path: /home/bookshub/mail/bookshub.ru/a.abramychev/sieve/tmp/managesieve_1712132381.M660921P2231265.hostname.domain.tld.sieve
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Debug: sieve: file storage: script `managesieve': Opened script `managesieve' from `/home/bookshub/mail/bookshub.ru/a.abramychev/sieve/tmp/managesieve_1712132381.M660921P2231265.hostname.domain.tld.sieve'
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Debug: sieve: file storage: script `managesieve': Opened script for reading
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Debug: sieve: file storage: script `managesieve': Closed script
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Debug: sieve: file storage: script `managesieve': save: Finished saving script
Apr 03 11:19:41 managesieve([email protected])<2231265><l4pq4iwVCIB/AAAB>: Info: Disconnected: Logged out bytes=291/868

Yes, sure!

The reason to ask once and again to check if it is marked as spam is because if the message is marked as spam, exim delivers the message directly to the maildir so sieve can’t see it and the sieve rules are not applied.

Said that, I can’t see any obvious problem, it should work :frowning:

Did you try the same with another account? At least one without a dot in the name just to test.

Yes, I tried to do this from the address a21network.info[@]yandex.ru и info[@]artpalmira.ru, but everything was the same, it didn’t discard it, nor did it mark it as SPAM!

I mean an acount in your server instead of a.abramychev

Sorry, I tried to do this with [email protected], but it also doesn’t discard ((

Then I’ve run out of ideas :frowning: I’ve the same conf and it works pretty fine.

I will think about it and if I see something that can help I will let you know.

1 Like

Thank you!
Could it be the filter code itself?
Well, that is, in the rules themselves?
Now he’s like this:

# rule:[Ozon]
if allof (header :contains "from" "[email protected]")
{
	discard;
}
# rule:[Yandex]
if allof (header :contains "from" "[email protected]")
{
	discard;
}

No, they look fine.

This is one of my rules that works pretty well.

# rule:[delete]
if allof (header :contains "from" "[email protected]")
{
        discard;
}