Maildrop Filter Question: Problem with Includes

View: New views
3 Messages — Rating Filter:   Alert me  

Maildrop Filter Question: Problem with Includes

by Patrick Lahni-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello everyone,

I've installed maildrop on my FreeBSD 7 machine with  
postfix+courier-imap.  I use mysql
for my virtual maps.  I'm trying to setup per-user maildrop filters in  
the virtual users'
folders; however for some odd reason the included file is ignored and  
subsequently not
parsed.  Any help would be appreciated to try and debug this.

Here are the permissions for the files in question ahead of time:

-rwxrwx---  1 vmail  postfix   3.5K Jun  9 20:16 /var/log/maildroprc.log
-rw-r--r--  1 root  mail   959B Jun  9 20:16 /usr/local/etc/maildroprc
-rwsr-xr-x  1 root  mail   168K Jun  9 19:57 /usr/local/bin/maildrop
-rw-r--r--  1 vmail  postfix   272B Jun  9 20:09
/usr/home/vmail/domain.tld/user2/mailfilter

The 'mail' group has the users 'vmail' and 'postfix'.

That being said, I have a default maildroprc file in /usr/local/etc  
with the following:

#!/usr/local/bin/bash

logfile "/var/log/maildroprc.log"
LOGNAME=tolower("$LOGNAME")

if ( $SIZE < 262144 )
{
     exception {
        xfilter "/usr/local/bin/spamc -f -u $LOGNAME"
     }
}

if ( `test -r $DEFAULT/mailfilter` == 0 )
{
     exception {
         log "Including $DEFAULT/mailfilter..."
         include "$DEFAULT/mailfilter"
     }
}

if (/^X-Spam-Flag: *YES/)
{
     exception {
         to "$DEFAULT/.Spam/"
     }
}
else
{
     exception {
         to "$DEFAULT"
     }
}

In my /var/log/maildroprc.log, the `log "Including  
$DEFAULT/mailfilter..."` line properly
outputs the correct location of my per-user mailfilter.  Such as the  
following:

Including /usr/home/vmail/domain.tld/user2//mailfilter...
Date: Mon Jun  9 20:16:53 2008
From: user1@...
Subj: 2
File: /usr/home/vmail/domain.tld/user2/                           (1443)

So I would assume that since the "Including" segment I had logged  
passes, the include
line immediately following that should be executed as well.

Here is user2's mailfilter:

if ( /^To: [0-9]+@test\.com:h )
{
     exception {
         log "email accepted!!!"
         to "|/path/to/script"
     }
}
else
{
     exception {
         log "email rejected!!!"
         EXITCODE=0
         exit
     }
}


I never see either of these 2 log lines in /var/log/maildroprc.log.  
Mail sent to
user2@... is delivered to its inbox like every other normal  
virtual user on the
machine.

Any help or insight as to how to try and track down why I cannot  
include per-user
mailfilters would be greatly appreciated!

Thanks in advance!

Patrick


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Courier-maildrop mailing list
Courier-maildrop@...
https://lists.sourceforge.net/lists/listinfo/courier-maildrop

Re: Maildrop Filter Question: Problem with Includes

by Devin Rubia :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Jun 09, 2008 at 08:56:20PM -0400, Patrick Lahni wrote:
> Here is user2's mailfilter:
>
> if ( /^To: [0-9]+@test\.com:h )

Perhaps a simple typo?  Where's the closing "/" on that pattern?

--
Devin

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Courier-maildrop mailing list
Courier-maildrop@...
https://lists.sourceforge.net/lists/listinfo/courier-maildrop

Re: Maildrop Filter Question: Problem with Includes

by mouss-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Patrick Lahni wrote:

> [snip]
> Here is user2's mailfilter:
>
> if ( /^To: [0-9]+@test\.com:h )
> {
>      exception {
>          log "email accepted!!!"
>          to "|/path/to/script"
>      }
> }
> else
> {
>      exception {
>          log "email rejected!!!"
>          EXITCODE=0
>          exit
>      }
> }
>
>
> I never see either of these 2 log lines in /var/log/maildroprc.log.  
> Mail sent to
> user2@... is delivered to its inbox like every other normal  
> virtual user on the
> machine.
>  

Apart from the typo mentioned by Devin, "user2@..." does not match
    ^To: [0-9]+@test\.com
[0-9]+ is all digits. it does not contain letters. This however does not
explain why the second log does not appear.


try running maildrop manually with some debug level. for example

    maildrop -V 6 -d blahblah < message.eml

run this as the user vmail.

I suggest replacing

if ( `test -r $DEFAULT/mailfilter` == 0 )
{
     exception {
         log "Including $DEFAULT/mailfilter..."
         include "$DEFAULT/mailfilter"
     }
...

with

exception {
        include "$DEFAULT/mailfilter"
        log "Including $DEFAULT/mailfilter..."
}

...


> Any help or insight as to how to try and track down why I cannot  
> include per-user
> mailfilters would be greatly appreciated!
>  


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Courier-maildrop mailing list
Courier-maildrop@...
https://lists.sourceforge.net/lists/listinfo/courier-maildrop
LightInTheBox - Buy quality products at wholesale price!