Mailing Lists writes:

> Hi folks, need an help.
> I set up my qmail-vpopmail system to filter mail via maildrop. So i put
> this two lines in my .qmail-default file
> 
> | /home/vpopmail/bin/vdelivermail '' bounce-no-mailbox 
> | /usr/bin/maildropmailfilter
> 

[...]
> Obviously, removing the firt line solve the problem, but invalid
> addresses are no more notified.

As yet there is no official solution to having user mail filters
automatically acted upon, but one is being worked on.  An interim
solution is to create a .qmail file in the user's directory (e.g.,
/home/vpopmail/domains/your.domain/user/.qmail with the line

  | /usr/bin/maildrop .mailfilter

Note that this .qmail file is NOT processed if mail is delivered
to the Maildir by an alias.  Qmailadmin generates aliases which
deliver direct to the Maildir (.qmail-user contains a path to the
Maildir) although this will change (has changed?) so that qmailadmin
crates aliases which actually work like forwards so that the users'
.qmail file is always processed.

An unofficial solution for use with vpopmail and the filters created by 
sqwebmail, is as follows.  You may be able to adapt it to whatever you're
using.  Basically, the patch means that if there is no .qmail file in the 
user's directory but it finds a .mailfilter file then it pretends that
it found a .qmail file containing the line shown in the interim solution.
If you're not using sqwebmail to generate filters then you'll have to
modify it accordingly.

1) Create /usr/local/share/sqwebmail/maildirfilterconfig (that's the
default location, you may have told sqwebmail to put its shared stuff
elsewhere) with the lines:

  MAILDIRFILTER=../.maildirfilter
  MAILDIR=./Maildir  

2) In vdelivermail.c, replace the function (and comments preceding it)
with this:

/* Check if the vpopmail user has a .qmail file in thier directory
 * and foward to each email address, Maildir or program that is found
 * there in that file.  If there is no .qmail file but there is a
 # .mailfilter file then invoke maildrop on the filter file.
 *
 * Return: 1 if we found and delivered email using .qmail or .mailfilter
 *       : 0 if not found either .qmail or .mailfilter
 *       : -1 if no user .qmail file or .mailfilter file
 *
 */
int check_forward_deliver(char *dir)
{
 static char qmail_line[500];
 char tmpbuf[500];
 FILE *fs;
 int i;
 int return_value = 0;
 int deliver_err;
   
    chdir(dir);

    /* format the file name */
    if ( (fs = fopen(".qmail","r")) == NULL ) {

        /* no .qmail file, so check for .mailfilter */
        if ( (fs = fopen(".mailfilter","r")) == NULL ) {
           
            /* no .qmail or .mailfilter file, so return -1 */
            return(-1);
        }
       
        /* there was no .qmail file but there was a .mailfilter
         * file so invoke maildrop */
       
       strcpy(tmpbuf, "| /usr/local/bin/maildrop .mailfilter");
       deliver_err = deliver_mail(tmpbuf, "NOQUOTA");
       if (deliver_err == -2) {
          printf("system error\n");
          vexit(111);
      } else if (deliver_err == -3) {
          printf("mail is looping\n");
          vexit(111);
      }
      return(1);
    }

    /* format a simple loop checker name */
    snprintf(tmpbuf, 500, "[EMAIL PROTECTED]", TheUser, TheDomain);

    /* read the file, line by line */
    while ( fgets(qmail_line, 500, fs ) != NULL ) {
        if (*qmail_line == '#') continue;

        /* remove the trailing new line */
        for(i=0;qmail_line[i]!=0;++i) {
            if (qmail_line[i] == '\n') qmail_line[i] = 0;
        }

        /* simple loop check, if they are sending it to themselves
         * then skip this line
         */
        if ( strcmp( qmail_line, tmpbuf) == 0 ) continue;

        deliver_err = deliver_mail(qmail_line, "NOQUOTA");
        if (deliver_err == -2) {
            printf("system error\n");
            vexit(111);
        } else if (deliver_err == -3) {
            printf("mail is looping\n");
            vexit(111);
        }
        return_value = 1;
    }

    /* close the file */
    fclose(fs);

    /* return if we found one or not */
    return(return_value);
}

-- 
Paul Allen
Softflare Support

Reply via email to