Spam -> Move to Junk

Discussion in 'Tips/Tricks/Mods' started by ZeroEnna, May 12, 2016.

Thread Status:
Not open for further replies.
  1. ZeroEnna

    ZeroEnna Member

    Hello board,

    I tried to do exactly that: Mails with X-Spam-Flag = YES should automatically move to Junk folder.
    I created a file /etc/dovecot/sieve/spam-to-folder.sieve with this content:

    require "fileinto";
    if header :contains "X-Spam-Flag" "YES" {
    fileinto "INBOX.Junk";
    }​

    and added it via sievec, then restarted dovecot. However, Spam mails are still stored in the inbox, instead of the junk folder.

    Any ideas?

    Regards
    Zero

     
  2. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    You might try just "Junk" for the folder name (that's what the
    'Move Spam Emails to Junk directory.' mailbox setting uses), and test adding a stop; after fileinto (maybe a later sieve script is simply moving it back to INBOX?)

    If still not working, make sure you have sieve_global_dir set in your dovecot config, and check the sieve log file to see if it indicates anything (I'm not sure where that'd be for a global script, just the user sieve log file, or maybe /var/log/mail.log ?).
     
  3. sjau

    sjau Local Meanie Moderator

    if you're using ISPConfig, you can setup sieve rules directly there.

    In the mailfilter tab of your account there's even a checkbox for: "Move Spam Emails to Junk directory."
     
  4. ZeroEnna

    ZeroEnna Member

    Seriously? Can I be that blind? Can it really be that simple? Gnahhhh :( Thank you, I was so dumb.
     
  5. sjau

    sjau Local Meanie Moderator

    well, doing it directly with sieve config files also works... and you learn a lot more by doing it that way ;)
     
  6. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    Or if you want global scripts that affect everyone, creating your own is the only way.
     
  7. slagroom

    slagroom Member

    How do I accomplish this? Is using a custom template for dovecot overriding other config for sieve? I mean, the ispconfig entry for plugins section in dovecot conf says:
    sieve_before=/var/vmail/%d/%n/.ispconfig-before.sieve
    so indeed, it grabs these settings from an ispconfig file per user. How do I override this globally then? Can I just add it, like:
    sieve_before=/var/vmail/%d/%n/.ispconfig-before.sieve /var/mail/globalmoveSpamtoJunk.sieve
    and put that entry in the plugins segment for a custom dovecot template or something?

    Also looked here:
    https://forum.howtoforge.com/thread...nk-directory-on-by-default.55801/#post-271750
    but it doesn't provide a persistent template overriding ispconfig updates..
     
    Last edited: Sep 14, 2023
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    Copy the file /usr/local/ispconfig/server/conf/sieve_filter.master to /usr/local/ispconfig/server/conf-custom/sieve_filter.master and then edit /usr/local/ispconfig/server/conf-custom/sieve_filter.master and change it in any way you like. The newly created file will get used for any new or updated mailbox then.
     
    slagroom likes this.
Thread Status:
Not open for further replies.

Share This Page