This is the very-very beginnings of a recipe for using the crm114 mailfilter as a spam filter with qmail+vpopmail+qmailadmin.
Use the code and information contained herein at your own risk.
The crm114 code and scripts presented here are the first workable fruits of asking the following question.
Can mailfilter.crm be used in a pop-only single-folder single-account context that permits the MUA (Mail User Agent, e.g. Outlook, Eudora, etc.) to flag spam while allowing the end user to train the filter which is located on the server, on a qmail+vpopmail server without requiring installation of any additional (non-qmail non-vpopmail) local-delivery software such as procmail, maildrop, or safecat?
The answer so far is yes. This strategy has been working apparently well with some caveats on my server since early in April 2005, i.e. for almost a month as of this writing.
The information provided here is intended to help someone wanting to accomplish a similar goal, who could probably have done something similar themself, but who may choose to use this code and information to get a head start. In particular, you should read about the crm114 mailfilter, install it, and make it do a few trivial things for you before you attempt to make any serious use of the information here.
Again, this is recipe for a server-side filtering aided by MUA detection of spam status headers generated by the crm114 "mailfilter.crm" filter. To work correctly, these scripts require that mailfilter.crm be configured in a particular ways. It is possible I may omit some information needed to use this code correctly, and while I intend to correct such omissions eventually, I also want to put up this information quickly, at the possible expense of completeness and accuracy. Also for now I am stating some things descriptively rather than technically because I don't have all the technical information at my fingertips. Again, use this at your own risk.
The code here is small. I am for now not providing a tarball, but rather a bunch of individual sources in a directory.
Known problems:
Other caveats:
CRM114 mailfilter configuration requirements:
Mail server configuration requirement:
Other configuration requirements:
Here is the directory containing all the code I used to enhance my qmail+vpopmail+qmailadmin system to support crm114 "mailfilter.crm"-based spam filtering which can be enabled on a per-user basis using qmailadmin:
You may have some problems with some of the source links in the above directory and in the links below if the file extension is not handled well by your browser. Personally I had trouble with the .sh file not being viewable, although my browser downloaded it
This will all not do you much good without some explanation. What follows is the briefest explanation.
The strategy used by this recipe is that the MUA can train the filter to recognize incorrectly classified messages by resending the misclassified mail to the server. A message is trained as spam by resending to a special spam address that the server administrators provides to end users who are permitted to do training. A message is trained as non-spam by resending a message to its final delivery address. Resend specifically refers to a function (often called "Redirect") which resends the entire message with all headers to a specified new destination address. With that background, what follows is an explanation of the purpose of each of the sources.
I put all of the above files in the /usr/bin directory on my server, which is also where crm114 is installed by default. The scripts use hard-coded references to other scripts assuming they are located in /usr/bin. You may need to correct this for use on your server.
If you want to use vpopmail's vdelivermail to avoid requiring procmail, maildrop, or safecat, you will need the following patch to vdelivermail.c, based on vpopmail version 5.4.10. I'm am not a patch guru and there is probably a better way of presenting this. Let me know if there are any problems. I have not yet tested applying this patch to the vpopmail sources!
==============================================================
--- vdelivermail.orig.c Wed Apr 6 05:07:36 2005
+++ vdelivermail.c Wed Apr 6 05:15:06 2005
@@ -52,6 +52,7 @@
struct vqpasswd *vpw;
off_t message_size = 0;
char bounce[AUTH_SIZE];
+char option[AUTH_SIZE];/*kkb*/
int CurrentQuotaSizeFd;
#ifdef QMAIL_EXT
@@ -177,6 +178,11 @@
vexit(111);
}
+ /*kkb begin*/
+ /* get the obsolete/option argument */
+ strncpy(option, argv[1], sizeof(option));
+ /*kkb end*/
+
/* get the last parameter in the .qmail-default file */
strncpy(bounce, argv[2], sizeof(bounce));
@@ -733,6 +739,14 @@
int deliver_err;
chdir(dir);
+
+ /*kkb begin*/
+ if ( strcmp(option, "-d") == 0 ) {
+
+ /* feature disabled, so just return */
+ return(-1);
+ }
+ /*kkb end*/
/* format the file name */
if ( (fs = fopen(".qmail","r")) == NULL ) {
==============================================================
This patch is discussed in the thread "how to do simple vpopmail delivery with filtering" on the "vchkpw" mailing list (vpopmail mailing list). For more information you may want to read this thread.
Good luck with any use you may make of this, and please feel free to send feedback to:
mailfilter DOT recipe AT breathhost DOT net.
Apologies for the preliminary state of this information, bug again, please understand that this information as currently provided in instended only as a help to someone who already knows what they are doing. If this description does not match you, and you choose to try to learn from it, you agree to accept the consequences of your choices. If the description does match you, then since you know what you are doing, then you are of course already responsible for your choices.
-Kurt Bigler, Berkeley, CA 4/29/05