We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
Understanding Spamassassin setup
Understanding Spamassassin setup
Hi,
I've used spamassassin on previous servers, but the config of the vestacp one seems to be a little different, so I'm trying to understand it.
I've created some rules and added them to /etc/spamassassin/local.cf. These deal with some obvious spam subjects that I get a lot of and bump up the spam score eg.
When I restart spamd those rules are applied. I understand I might also put them into a separate .cf file in the same directory.
HOWEVER, other settings I change in local.cf don't seem to be obeyed. I would like to rewrite the header with a [*SPAM*] flag. When I change this in local.cf, nothing happens. How do I do this?
I also notice that changing the spam score in local.cf doesn't work. I have discovered the spam score directive in the /etc/exim4/exim.conf.template. Changing this does have an effect on the spam detection threshold (although I notice that 50 in the exim conf corresponds to 5.0 in the spamassassin conf!).
Finally I have a problem with the way spam is handled. When it is detected, it is moved immediately to the spam directory of my mail account on the server. As I access my mail by POP3, I never get to see what is spam and what isn't. I only get the contents of my Inbox. So its not until I use Webmail or access by IMAP, that I see all the spam, and discover some emails from weeks ago that have been miscategorised.
What I'd prefer to do is to give each email a spam score (and re-write the header), but for it to remain in my inbox on the server. Then when I pull it down to my desktop via POP, I can use the POP client's filtering to divert spam into a separate folder for review. How would I do this?
I've used spamassassin on previous servers, but the config of the vestacp one seems to be a little different, so I'm trying to understand it.
I've created some rules and added them to /etc/spamassassin/local.cf. These deal with some obvious spam subjects that I get a lot of and bump up the spam score eg.
Code: Select all
header OBVIOUS_PILLS Subject =~ /(Viagra[ .]|Cialis[ .]|Levitra[ .]|ED med|ED pill|VPXL)/
score OBVIOUS_PILLS 100
HOWEVER, other settings I change in local.cf don't seem to be obeyed. I would like to rewrite the header with a [*SPAM*] flag. When I change this in local.cf, nothing happens. How do I do this?
I also notice that changing the spam score in local.cf doesn't work. I have discovered the spam score directive in the /etc/exim4/exim.conf.template. Changing this does have an effect on the spam detection threshold (although I notice that 50 in the exim conf corresponds to 5.0 in the spamassassin conf!).
Finally I have a problem with the way spam is handled. When it is detected, it is moved immediately to the spam directory of my mail account on the server. As I access my mail by POP3, I never get to see what is spam and what isn't. I only get the contents of my Inbox. So its not until I use Webmail or access by IMAP, that I see all the spam, and discover some emails from weeks ago that have been miscategorised.
What I'd prefer to do is to give each email a spam score (and re-write the header), but for it to remain in my inbox on the server. Then when I pull it down to my desktop via POP, I can use the POP client's filtering to divert spam into a separate folder for review. How would I do this?
Re: Understanding Spamassassin setup
OK, I got around to figuring this out.
So first part of the puzzle was to force exim not to put the Spam into the Spam folder, but to leave it in my inbox, so I could download it and process it in my local client. This stops a huge buildup of spam on the server and allows me to immediately see if some real mail has been miscategorised.
In the Transport section of /etc/exim4/exim4.conf.template find the section for local_spam_delivery and remove the last bit of the directory line. eg
OK, the next bit was trickier. We can't just rewrite the Subject. First we add a header to the email in the section that evaluates the spam score. The section starts with ".ifdef SPAMASSASSIN" and you want to put it under the line about spam scores
This adds eg [*SPAM=56*] before the email subject, and stores it as a different header called X-Spam-Subject
Now we have to remove the old subject and replace it with the X-Spam-Subject. I tried to do this in the Transport section, but couldn't get it to work, so i put it in a filter.
- Make a filter file:
- add it to your config by adding these lines to exim4.conf.template just before the ACL section
- Now add the code to switch the headers in the system_filter file
run update.exim4.conf and then restart exim4 service.
So first part of the puzzle was to force exim not to put the Spam into the Spam folder, but to leave it in my inbox, so I could download it and process it in my local client. This stops a huge buildup of spam on the server and allows me to immediately see if some real mail has been miscategorised.
In the Transport section of /etc/exim4/exim4.conf.template find the section for local_spam_delivery and remove the last bit of the directory line. eg
Code: Select all
# directory = "${extract{5}{:}{${lookup{$local_part}lsearch{/etc/exim4/domains/$domain/passwd}}}}/mail/$domain/$local_part/.Spam"
directory = "${extract{5}{:}{${lookup{$local_part}lsearch{/etc/exim4/domains/$domain/passwd}}}}/mail/$domain/$local_part/"
Code: Select all
condition = ${if >{$acl_m2}{SPAM_SCORE} {yes}{no}}
add_header = X-Spam-Status: Yes
add_header = X-Spam-Subject: [*SPAM=$spam_score_int*] $h_Subject
Now we have to remove the old subject and replace it with the X-Spam-Subject. I tried to do this in the Transport section, but couldn't get it to work, so i put it in a filter.
- Make a filter file:
Code: Select all
touch /etc/exim4/system_filter
chown Debian-exim /etc/exim4/system_filter
Code: Select all
system_filter = /etc/exim4/system_filter
system_filter_user = Debian-exim
Code: Select all
if $h_X-Spam-Status: contains "Yes"
then
headers remove "Subject"
headers add "Subject: $h_X-Spam-Subject"
endif