mark Junk as read and $Junk

Discussion in 'Installation/Configuration' started by bax, Mar 31, 2014.

  1. bax

    bax Member

    Hi there!

    I did not find an option in ISPConfig3 to do the following:

    1. I want spam to be sorted into the "Junk" Mailbox (working so far, easy to find).

    2. I want my spam to be flagged as read
    3. I want my spam to be flagged as $Junk (or whatever works best with my mail clients)

    Part 2 and 3 are hard: As far as I understood I would have to set
    Code:
    require "imap4flags";
    in the sieve rules of the mailboxes.
    However, since "require" commands are only allowed before any rules are executed, this doesn't work.

    I actually would have expected these behaviors to be the default (flag es read and junk).

    Is there any other way I could make this work?

    Thank you!
     
  2. srijan

    srijan New Member HowtoForge Supporter

    Hi

    Please refer the link for the spam policies.

    Br//
    Srijan
     
  3. bax

    bax Member

    @srijan

    Thank you for you reply.
    Where would I set this?
    I'm using dovecot and sieve and was looking for a solution I could set within ISPConfig3.
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    What srijan posted does not apply to your setup which uses sieve.

    In ISPConfig, you can add sieve rules in the custom rules field of the mailbox. something like this might work:

    Code:
    if header :contains "X-Spam-Flag" "YES" {
      addflag "\\Seen";
      fileinto "Junk";
      # Stop here so that we do not reply on spams
      stop;
    }
    
     
  5. bax

    bax Member

    @till
    Thank you for your reply.
    I already tried something similar but it seems like I would have to set require "imap4flags"; to make it work.
    But that won't work since "require" has to be called before any rules are executed and the custom rules are executed after the standard rules are called…
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Copy the file sieve_filter_1.2.master from /usr/local/ispconfig/server/conf/ to /usr/local/ispconfig/server/conf-custom/ and then edit the require line in /usr/local/ispconfig/server/conf-custom/sieve_filter_1.2.master and add imap4flags. The changes will get applied when you change the mailbox the next time.
     
  7. bax

    bax Member

    @till
    Thank you!

    I didn't even know that this folder existed!
    It's not mentioned in the pdf documentation (by which – by the way – I was really disappointed: It doesn't really go into detail anywhere).

    I changed the whole start of the file to look like this:

    Code:
    
    require ["fileinto", "imap4flags", "regex", "date", "relational", "vacation"];
    
    <tmpl_if name="cc">
    # Send a copy of email to
    redirect "<tmpl_var name='cc'>";
    </tmpl_if>
    
    <tmpl_if name="move_junk" op="==" value="y">
    # Move spam to spam folder
    if header :contains "X-Spam-Flag" "YES" {
      setflag "\\Seen";
      addflag "$junk";
      fileinto "Junk";
      # Stop here so that we do not reply on spams
      stop;
    }
    </tmpl_if>
    
    
    Now all junk mail is being marked as read and marked as "spam" in apple mail.
    I think this should be the default!
     

Share This Page