Rspamd rewrite subject without moving to junk folder

Discussion in 'General' started by Shaky, Jan 4, 2024.

Tags:
  1. Shaky

    Shaky New Member

    Hello,
    I did a fresh ISPConfig install on a new server and migrated all data from the old server with the migration tool. On the old server with spamassassin my spam "tagging" was set up the following way:
    1. rewrite subject at a certain spam score (e.g. 3.0)
    2. move mail to junk folder at even higher score (e.g. 6.0)
    3. reject high spam score mails (e.g. above 15.0)
    With Rspamd I can't find a way to do it this way. As soon as the subject is rewritten the mail gets moved to junk. But it should only be moved on a higher score. For me having the "***SPAM***" subject only in the junk folder is absolutely redundant, I'd like to have the subject rewritten in the inbox as a first warning sign.
    So my question is: Is there a way to manually rewrite the subject for every mail above a certain score (e.g. via an action in override.d) without moving it to junk? Ideally this could be set somehow via ISPConfig on a per user basis.

    ISPConfig v3.2.11p1 installed with auto installer on Debian 12
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    If a mail i moved to junk is not controlled by Rspamd or Amavis at all, it is controlled by Dovecot or your email client. There is a select box on the filter tab of the mail account which controls if a email gest moved to junk.
     
  3. Shaky

    Shaky New Member

    I'm sorry, I expressed myself misleadingly. I want spam to be moved to junk but with a higher score than the rewrite subject score.
    The mail's subject should be rewritten above a score of 3. But it should be moved to Junk at score 6 or higher.

    Dovecot moves the mail due to the X-Spam tag, as far as I know. But there is no way to rewrite the subject in Rspamd without setting this tag as the subject is only rewritten when Rspamd classifies the mail as spam.
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Rspamd writes a line like this into the header:

    Code:
    X-Spam-Level: ********
    That you can use to create a filter to move the email to any folder you like, incl. the Junk folder. One * is 1, so ******** is score 8.
     
  5. Shaky

    Shaky New Member

    Thank you Till for the hint and your prompt reaction.
    This is not the solution I was looking for but it's better than none. Ideally I'd like to have an extra "SPAM move level" field in the Rspamd section of the spam policy form. Relying on the "X-Spam-Status" for Rspamd by default is not very elegant.

    My solution for now is to move mails with a score greater than 8 to junk for all users. Therefore I copied the file "/usr/local/ispconfig/server/conf/sieve_filter.master" to "/usr/local/ispconfig/server/conf-custom" and replaced the two "Move spam to spam folder" conditions with
    Code:
    if anyof (header :is ["X-Spam", "X-Spam-Flag"] "Yes", header :contains "X-Spam-Level" "********") {
      fileinto :create "<tmpl_var name='imap_prefix'>Junk";
      # Stop here so that we do not autoreply on spams
      stop;
    }
     

Share This Page