mark_nl
(Mark Verlinde)
August 20, 2018, 1:31pm
21
IMHO if , as @AndreLinux just confirmed, mails with the header addition X-getmail-filter-classifier: Action: rewrite subject
are spam,
it is enough to simply move them to the Junk
folder with a adoption in the before.sieve
without actually rewiring the subject.
@AndreLinux what do you think?
stephdl
(Stéphane de Labrusse)
August 20, 2018, 1:37pm
22
yes but nothing will be done if the checkbox move to junk
is disabled
1 Like
The subject is not actually rewritten, it remains unaltered. It is only the header that changes.
mark_nl
(Mark Verlinde)
August 20, 2018, 2:06pm
24
Is this different behavior as with âX-SPAM-FLAGâ âYESâ
?
mark_nl
(Mark Verlinde)
August 20, 2018, 2:11pm
25
But would it be good enough for you if the mails are moved to the Junk folder without rewriting the subject?
Rewriting the subject does not seem to be a simple task in our setup.
thorsten
(Thorsten)
August 20, 2018, 2:26pm
27
Today I got an E-Mail from Univention which I tried before Nethserver. I am still on the mailing list. It was send to one of the domains I handle using Nethserver (my old myname.dyndns.org adress): The subject was replaces to anounce its spam status and it was moved to junk - at least this part seems to work âŠ
stephdl
(Stéphane de Labrusse)
August 20, 2018, 4:08pm
28
this is the postfix milter job, this is the normal way to handle email
stephdl
(Stéphane de Labrusse)
August 20, 2018, 4:09pm
29
this could be just another sieve script in before.sieve provided by nethserver-mail2-getmail
1 Like
thorsten
(Thorsten)
August 21, 2018, 10:59am
30
Yes, that is my expectation, too. Just from this discussion, I was not sure if it works on my system at all
stephdl
(Stéphane de Labrusse)
August 25, 2018, 10:27am
31
Just a first workaround, replace the file with the content below
nano /etc/e-smith/templates/var/lib/nethserver/sieve-scripts/before.sieve/10junkmail
#
# 10junkmail
#
{
return '# -- disabled (Spam is delivered to INBOX)' if ( ! $dovecot{SpamFolder});
$OUT .= qq(
# -- enabled (move marked SPAM messages into junkmail folder)
require ["fileinto", "mailbox","regex"];
if header :contains "X-Spam-Flag" "YES" {
fileinto :create "$dovecot{SpamFolder}";
stop;
}
# -- enabled (move spam subject to junkmail folder)
if header :regex ["X-getmail-filter-classifier"] ["add header"] {
fileinto :create "Junk";
stop;
}
);
$OUT .= qq(
# -- enabled (move spam subject to junkmail folder)
if header :contains "subject" "$rspamd{SpamSubjectPrefixString}" {
fileinto :create "$dovecot{SpamFolder}";
stop;
}
# -- enabled (move spam subject to junkmail folder)
if header :regex ["X-getmail-filter-classifier"] ["rewrite subject"] {
fileinto :create "Junk";
stop;
}
) if (($rspamd{SpamSubjectPrefixString}) && ($rspamd{SpamSubjectPrefixStatus} eq 'enabled'));
}
it is not supposed to rewrite the subject, only to move to junk when the header add header
or rewrite subject
is found
1 Like
stephdl
(Stéphane de Labrusse)
August 25, 2018, 10:50am
32
Maybe we could have a solution to change the header subject with sieve
reading this it could be possible to delete a header and to make it again with a new value : https://tools.ietf.org/html/rfc5293
not tested yet, a bit tricky with the risk to delete an important header and break the email
1 Like
stephdl
(Stéphane de Labrusse)
August 25, 2018, 1:34pm
33
ok we could rewrite the subject with dovecot/sieve
in /etc/dovecot/dovecot.conf
- sieve_extensions = +imapflags
+ sieve_extensions = +imapflags, +editheader
restart dovecot
in /var/lib/nethserver/sieve-scripts/before.sieve
- require ["fileinto", "mailbox"];
+ require ["fileinto", "mailbox","editheader","variables","regex"];
+ if header :matches "Subject" "*" {
+ set "subjwas" ": ${1}";
+ }
+ if header :regex ["X-getmail-filter-classifier"] ["rewrite subject"] {
+ deleteheader :index 1 "subject";
+ addheader :last "subject" "***SPAM*** ${subjwas}";
+ }
if header :contains "X-Spam-Flag" "YES" {
fileinto :create "Junk";
stop;
}
no need to install an extra rpm or service
@dev_team what do you think
create a sieve script to rename the subject if matches rewrite subject
(our ***spam***
sieve rule should put it after to junk)
or
create a sieve script to move to junk if matches rewrite subject
or add header
(if MoveToJunk is enabledâ)
5 Likes
thorsten
(Thorsten)
August 25, 2018, 9:19pm
34
thorsten
(Thorsten)
August 26, 2018, 7:32am
35
What is the correct module to apply changes for?
Is it
signal-event nethserver-mail-filter-save
thorsten
(Thorsten)
August 27, 2018, 11:29am
36
WORKS! Spam mail collecte via Getmail ist placed in the corresponding spam folders!
1 Like
emails colleted by getmail and considered as spam by rspamd are correctly moved to the junk folder with the modified object.
1 Like