Opened 9 years ago

Closed 8 years ago

#3302 closed Question/How do I...? (fixed)

Possible to automatically add IMP/Horde spam filtering rule to all accounts?

Reported by: Owned by:
Priority: Medium Component: Tech
Keywords: IMP/Horde, spam, filtering, webmail, SSH, root access, user accounts Cc:
Sensitive: no


I'd like to filter out spam from all of our users' email folders when they use webmail, as specified in this document:

Is there any way to do this programmatically by adding/editing a text file in each account, so I can quickly add to every account:

  • The filtering rule
  • The Spam folder
  • Filtering upon logging in
  • Unsetting "Display detailed notification when each filter is applied" so that they see the number of messages moved, but not a page full of spam email subject lines

It's going to take a while if I have to do each account one at a time through the web interface.

I just added this configuration to the account iboothe, so if you know where the configuration file(s) might be, I can copy them over to the other accounts, if such a thing is possible.


Change History (17)

comment:1 Changed 9 years ago by

Well, I went ahead and did it all manually. But I'm still curious if it might be possible to set these settings programatically somehow.

comment:2 Changed 9 years ago by

Sorry for not getting back to you sooner - we don't have a way to automate this for all users on horde, unfortunately.

I think that might be a decision worth re-visiting - particularly with spam.

However - it is possible to setup filtering rules for each user on the IMAP server itself (which in some ways is better because the filters will happen no matter what email client you are using).

The only problem is that you have to enable SSH for each user and then up load a .mailfilter file into each user's home directory with something such as:

# ensure a detected-spam folder exists
`test -d $HOME/Maildir/.detected-spam`
if( $RETURNCODE == 1 )
  `/usr/bin/maildirmake $HOME/Maildir/.detected-spam`

# get rid of spam
if (/^X-Spam-Flag: YES/)
	to "Maildir/.detected-spam/"

It might be worth revisiting whether this filter rule should be added globally.


comment:3 Changed 9 years ago by

Ah, interesting, I was wondering if it could be done at the server level. Yes, that could work. Could I disable SSH for them after I put that file in, or will they all have to have SSH in order for that to function?

I fully understand and support your "marking spam but not blocking it" principle, but in our case I know 99% of the staff would really like it filtered for them -- and since some of them switch between webmail, email programs and a mobile device, this could make it a lot easier.

comment:4 Changed 9 years ago by

Yes - you can disable ssh access after placing the file in their home directory. Be sure to test on one user before adding it for the rest :).


comment:5 Changed 9 years ago by

  • Keywords SSH root access user accounts added

OK, I've enabled it for my personal account and it seems to be working. One question though: It doesn't seem like the main account (forusaweb) has access to any of the other users' accounts. This makes sense by default, but is it possible for us to grant it permission to those other accounts? Otherwise I'm going to have to get each person's password which...would not be a fun process. And in general I can think of other use cases (e.g. backing up email) where we might want that main account user to have access to other of our users' accounts. Is that a possibility?

If that's not possible, can I attach the file and have you deposit it in each of those user accounts?

comment:6 Changed 9 years ago by

I can add it to your user's directories if you like.

Another option would be for you to install your ssh key (via the members control panel) on each users account (when you enable ssh access, you can optionally add a key). Then you could ssh/sftp without needing to know their passwords.


comment:7 Changed 9 years ago by

OK -- here's the filter file for now (altered only slightly from yours as I'd already created folders named "Spam"), if you could put it in all the user accounts (it's already in iboothe) that would be great. Let me know if I need to enable SSH access to all the accounts first.

Later on I'll look into installing the SSH keys as that does seem like a good idea.

# ensure a detected-spam folder exists
`test -d $HOME/Maildir/.Spam`
if( $RETURNCODE == 1 )
  `/usr/bin/maildirmake $HOME/Maildir/.Spam`

# get rid of spam
if (/^X-Spam-Flag: YES/)
	to "Maildir/.Spam/"

comment:8 Changed 9 years ago by

Ok - done. Let me know if you notice any mail delivery problems.


comment:9 Changed 9 years ago by

Hmm. I just checked it on the forbookstore account, using Mac, and the spam doesn't seem to be getting filtered -- you said this was on the server-side, so this should work regardless of email application, right?

I can give you the password to that account if you want to play with it.

comment:10 Changed 9 years ago by

Yes - should not matter what application you are testing with.

I just sent a message with the gtube code in the body of the message and it was properly filtered. I also enabled a mailfilter log for the user so you can see a log of what maildrop is doing (you will need to ssh/sftp into the user's account to see it).


comment:11 Changed 9 years ago by

Oh I've got it -- naturally it only affects mail coming in from that point on, not spam sitting in the inbox. Makes sense.

comment:12 Changed 9 years ago by

Ah yes - that is correct.


comment:13 Changed 9 years ago by

  • Resolution set to fixed
  • Status changed from new to closed

Working great now. Thanks!

comment:14 Changed 8 years ago by

  • Resolution fixed deleted
  • Status changed from closed to reopened

We have three new accounts that have been created, can you add the same script above to these accounts?

The accounts are: johnlp spimiento lsmith

No particular rush on this, since they're brand-new accounts and shouldn't be getting much spam, but if you could take care of it by the end of next week that would be great.

comment:15 Changed 8 years ago by


This is Mark Libkuman, Jamie is offline till Tuesday and i'm helping moderate the support queue. I currently don't have root access to the rodolpho server which is your primary host so i cannot do this for you right now. Jamie will be back at his computer on Tuesday and it sounds like an easy thing to do so it should be quite easy to get this done by the end of next week.

cheers, Mark

comment:16 Changed 8 years ago by

No problem, just let me know when it's done.

comment:17 Changed 8 years ago by

  • Resolution set to fixed
  • Status changed from reopened to closed

Hi All - the .mailfilter file has been copied into place for all three users.


Please login to add comments to this ticket.

Note: See TracTickets for help on using tickets.