Hi people, I have to ask a huge favour to help me resolve a very strange issue 
that I have.

I know this is not specifically related to qmail-ldap, but I am hoping that 
some people on the list can give me some help on some of the qmail-ldap 
internals.
I use maildrop with a filter script executed by the deliveryProgramPath 
attribute.

My filter script does this:
check that the user is not over quota
if not over quota, filter messages < 250k through spamc if over 250k, deliver 
to inbox.
if spam, deliver into spam folder else deliver into inbox.

This all works except the over quota part. I use 'bouncesaying' to bounce the 
messages that are overquota (determined by an external perl script that 
returns 1/0 if over quota or not). 
If the messages are less than 50k, they are bounced correctly with the error 
configured by the bouncesaying argument . If they are over 50k, they are not 
bounced, instead, the message is deferred and returned to the local queue. 
My C is not that sharp that I understand what is happening within the  
bouncesaying code, but for some reason, maildrop seems to think that 
bouncesaying is failing and then returns an error code to qmail-local so that 
the mail is deferred.

I have attached my filter script in it's entirety so that people can look have 
a look to see if there is a better way of doing what I am trying to do. I 
have also attached some logs to show that some messages are deferred, while 
other messages (under 50k) are bounced. 
I have santized some of the log files to cover up mail addresses etc...

Successful bounce:
@4000000044eebbb203cc9e3c delivery 1064860: failure: 
_MAILDIRQUOTA:_165000000S,500002C/__QMAILDELIVERYPROGRAM:_maildrop_/var/qmail/mail/maildrop_SPAM_filter1/__QMAILMODE:_nolocal/__QMAILDOTMODE:_both/__executing_'qmail-local_--_USER_/var/qmail/mail/new/m/u/MAILDIR/_USER___USER_SENDER_./'_under_uid=120,_gid=120/_Sorry_USER_is_over_their_allocated_QuotaSize_or_QuotaCount/

Deferred Message:
@4000000044eebc0d3136ceec delivery 1064916: deferral: 
_MAILDIRQUOTA:_165000000S,500002C/__QMAILDELIVERYPROGRAM:_maildrop_/var/qmail/mail/maildrop_SPAM_filter1/__QMAILMODE:_nolocal/__QMAILDOTMODE:_both/__executing_'qmail-local_--_USER_/var/qmail/mail/new/m/u/MAILDIR/_USER___USER_SENDER_./'_under_uid=120,_gid=120/_Sorry_USER_is_over_their_allocated_QuotaSize_or_QuotaCount/maildrop:_error_writing_to_mailbox./maildrop:_Unable_to_deliver_to_mailbox./


I would really appreciate any help that anyone has to offer, even if it is 
just the understanding of the internals of bouncesaying 

-- 
Regards,

Scott Ryan
Telkom Internet
# SPAM Maildrop Filter
# Scott Ryan Aug 2006
#####################

SHELL=/bin/sh
logfile "/var/log/maildrop.log"
log "====  BEGIN maildrop processing for $USER ==="

# Import mail quotas
import MAILDIRQUOTA
import USER

# Check Available Quota
QUOTACHECK=`checkquota1.pl $USER $SIZE 1`
#QUOTACHECK="1"
log "Quotacheck:$QUOTACHECK"

if ( $QUOTACHECK == 1 ) 
{
        # Bounce Message User is Over Quota
        log "$USER is over quota"
        to "|/var/qmail/bin/bouncesaying 'Sorry $USER is over their allocated 
QuotaSize or QuotaCount'"
}
else
{
        # Check Mail Size - If > 250k - dont filter
        if ( $SIZE > 262144 )
        {
                # Mail too big, deliver to inbox
                exception {
                to "|deliverquota -w 90 ./"
        #       xfilter "deliverquota -w 90 ./$SPAM_FOLDER"
                }
                log "ExitCode:$EXITCODE"
        }
        else
        {
                # Not Over Quota, Not too big, Check mail for Spam with 
SPAMASSASSIN
                xfilter "spamc -u $USER"
                if (/^X-Spam-Flag: *YES/)
                {
                        # Mail is determined as spam deliver to mailbox
                        # Check for SPAM Folder 
                        `test -d "./.SPAM"`
                        if( $RETURNCODE == 0 )
                        {
                                # .SPAM Folder Exists
                                SPAM_FOLDER=".SPAM/"
                        }
                        # Deliver Mail
                        exception {
                                to "|deliverquota -w 90 ./$SPAM_FOLDER"
                        }
                        log "ExitCode:$EXITCODE"
                }
                else
                {
                        # Not Spam, Not over Quota... Deliver Mail
                        exception {
                                #to "./"
                                #xfilter "deliverquota -w 90 ./$SPAM_FOLDER"
                                to "|deliverquota -w 90 ./"
                        }
                        log "ExitCode:$EXITCODE"
                }
        }
}

Reply via email to