Hello.

With some simple changes to courier IMAP, it's easy to install a learning system for spam mail. The system relies on the creation of two simple scripts, which courier will launch when the user moves messages to two special folders. Those folders are checked for existence after the user login into courier IMAP, and they are created automaticly if not present.

The modification to courier IMAP is easy: when the user moves messages to a folder called "LearnSPAM", a script called "LearnSPAM.sh" (which must be in a location in the PATH system variable) is launched with the user name as a parameter. Such script should be created depending on which anti-spam package is in use, and should perform the necessary tasks so such subfolder in the user's homedirectory is processed by the anti-spam package to learn. When the user moves messages to a folder called "LearnNoSPAM", a script called "LearnNoSPAM.sh" is launched as well, with the user name as a parameter. Such script should interface with the anti-spam package as well so it learns that such messages are not spam.

That way, we avoid the need of having a script which scans every user LearnSPAM/LearnNoSPAM folders on a timely basis, meaning that we are only going to scan such folder for a user when it's really needed.

The patch applies to the imapd.c file.

Cheers.
691a692,693
>       // fprintf(stdout, "[%s %s]", mailbox, getenv ("AUTHENTICATED"));
> 
4522a4525
>                       //writes (mailbox);writes("\r\n");
5933a5937
>               
5972a5977,6011
>                       // variables needed to Learn/LearnNoSPAM
>       
>                       const char *jL_username = getenv ("AUTHENTICATED");
>                       char    *jL_comando;
>                       char    *jL_mailbox;
>       
>                       // fin
>                       
>                       // jL: Launch auto-learning scripts if messages are 
> moved to
>                       // "LearnSPAM" or "LearnNoSPAM";
>                       
>                       // Copy stuff for safety.
>                       
>                       jL_mailbox = strdup (mailbox);
>                       
>                       if ( strstr (jL_mailbox, "LearnSPAM") ) {
>                               writes ("launching script LearnSPAM.sh\r\n");
>                               jL_comando = strdup ( "LearnSPAM.sh " );
>                               jL_comando = (char *) realloc ( jL_comando, 
> strlen (jL_comando) + strlen (jL_username) + 1 );
>                               jL_comando = strcat ( jL_comando, jL_username );
>                               system ( jL_comando );
>                       } else if ( strstr (jL_mailbox, "LearnNoSPAM") ) {
>                               writes ("launching script LearnNoSPAM.sh\r\n");
>                               jL_comando = strdup ( "LearnNoSPAM.sh " );
>                               jL_comando = (char *) realloc ( jL_comando, 
> strlen (jL_comando) + strlen (jL_username) + 1 );
>                               jL_comando = strcat ( jL_comando, jL_username );
>                               system ( jL_comando );
>                       }
>                       
>                       free (jL_comando);
>                       free (jL_mailbox);
>               }
> 
> 
>               {
6282a6322,6324
>               
>               //
>               //
6368a6411
> 
6474a6518,6542
>               
>       // jL: Check if LearnSPAM and LearnNoSPAM exist and create them if they 
> don't.
>       {
>               DIR *directorio;
>               
>               // I check if ./.LearnNoSPAM exists, otherwise I create it.
>                               
>               if ( !(directorio = opendir ("./.LearnNoSPAM")) ) {
>                       writes ("Folder 'INBOX.LearnNoSPAM' not found. Creating 
> 'INBOX.LearnNoSPAM'\r\n");
>                       mdcreate ("./.LearnNoSPAM");
>               } else {
>                       closedir (directorio);
>               }
>               
>               // I check if ./.LearnSPAM exists, otherwise I create it.
>               
>               if ( !(directorio = opendir ("./.LearnSPAM")) ) {
>                       writes ("Folder 'INBOX.LearnSPAM' not found. Creating 
> 'INBOX.LearnSPAM'\r\n");
>                       mdcreate ("./.LearnSPAM");
>               } else {
>                       closedir (directorio);
>               }
>       }
>       
>               
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
courier-users mailing list
[email protected]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users

Reply via email to