[Help] Dovecot to send X-Spam-Flag emails to Junk folder

  • Hi,

    First, I'm sorry if this is not the place to create this topic, but I think is the better place to do it.

    I'm trying to create my first Listener, but I'm don't have any knowledge on Perl, so i need some explanations, or ideas to implement it.

    Problem: There are many SPAM emails in INBOX folder after Spamassasin catalog them with X-Spam-Flag = YES

    Solution: To add a small filter in dovecot to move them to Junk folder.

    In order to do this, I need to change some parameters in /etc/dovecot/dovecot.conf

    To add "sieve = /etc/dovecot/sieve/default.sieve" inside plugin context:

    1. plugin {
    2. quota = maildir:User quota
    3. quota_rule = *:storage=1G
    4. quota_rule2 = INBOX.Trash:storage=+100M
    5. quota_warning = storage=95%% quota-warning 95 %u
    6. quota_warning2 = storage=80%% quota-warning 80 %u
    7. sieve = /etc/dovecot/sieve/default.sieve
    8. }

    To modify mail_plugins inside protocol lda, but not mail_plugins line above the document.

    1. protocol lda {
    2. auth_socket_path = /var/run/dovecot/auth-master
    3. mail_plugins = $mail_plugins sieve
    4. postmaster_address = [email protected]
    5. }

    Finally, to create this document with vmail:mail permissions on /etc/dovecot/sieve/default.sieve

    1. require "fileinto";
    2. if header :contains "X-Spam-Flag" "YES" {
    3. fileinto "INBOX.Junk";
    4. }

    Basically, I'm trying to do for myself looking other listeners, but I don't understand pretty well and I don't know how to add a line inside a context, how to replace mail_plugins line, when I have 2 different on the document, and I don't know how to create a document with permissions.

    Thank you in advance for your help.

  • theemstra

    Added the Label question