Am 17.10.2008 um 14:28 schrieb Reinaldo de Carvalho:

I wrote a polycd-daemon (python) to check quota on cyrus using imap
protocol (as cyrus admin user).

This policy-daemon search on ldap to check if email is a alias, to get
and retrive quota from real user.

This program is not complete to public distribution, I wrote on
half-hour to a customer. Many options as hard-coded and you need read
and understand the code to be usefull for you.

http://www.nautilus.com.br/~rei/material/lost+found/policyd-quota


Hello Reinaldo,

thanks for the link. I will have a look at it, though ruby would be more
up my alley ;)

Here is the final version of my procmailrc file, maybe it could be useful
for somebody else as well....

LOGFILE="/var/log/procmail"
VERBOSE=no

# command definitions
CHECKSUM=/usr/bin/md5sum
DQ='"'
DELIVERMAIL="/usr/lib/cyrus-imapd/deliver"
MAILDOMAIN="dbap.de"
DAEMON="[EMAIL PROTECTED]"
SENDMAIL="/usr/sbin/sendmail -i -f $DAEMON -t $SENDER"
INBOX="$DELIVERMAIL -f $SENDER -a $USER $USER"

# initalize vars
NL = "
"
LOCALRECIPIENT=`formail  -t -xTo:`
ORIGINALSENDER=`formail -rt -xTo:`
LOG=`date`": Processing mail from ${ORIGINALSENDER} to $ {LOCALRECIPIENT}${NL}"

# enable / disable spam && virus check
CHECK = 0

:0
* $CHECK ?? 0
{
  LOG=`date`": Spam and Viruschecks are disabled.${NL}"
}

# Spamassassin && ClamAV
:0
* $CHECK ?? 1
{
        LOG=`date`": Starting spam check... ${NL}"
        :0fw
        * < 110000
        | /usr/bin/spamc -u filter

        LOG=`date`": Starting virus check... ${NL}"
        :0fw
        | /usr/local/bin/clamassassin

        :0
        * ^X-Virus-Status: Yes
        {
LOG=`date`": The message from ${ORIGINALSENDER} to ${LOCALRECIPIENT} contained a virus and was deleted.${NL}"
                :0
                /dev/null
        }
}

# deliver to INBOX
:0 w
| $INBOX

# if this went wrong
:0 e
{
        EXITCODE=$?

        # drop all non temporary errors (e.g. Mailbox does not exist etc.)
        :0
        * ! EXITCODE ?? 75
        /dev/null

        # temporary failure?
        :0 w
        * EXITCODE ?? 75
        {
                EXITCODE=0

                :0
                * ^X-Loop: $DAEMON
                /dev/null

                :0
                {
                        BOUNCEPID=`echo $$`
LOCALDOMAINMX=`dig MX +short ${MAILDOMAIN}|sed -e 's/. / /g' -e 's/.$//g' |awk '{print $1}'`
                        DATE=`date`
MIMEBREAK="`cat bouncetemp.${BOUNCEPID} | $ {CHECKSUM} | sed -e 's/ -//'`.`date '+%s'`/${HOST}.${MAILDOMAIN}" LOG=`date`": local delivery to ${LOCALRECIPIENT} for this message had a temporary error. Bounce message to ${ORIGINALSENDER} will be send.${NL}"
                }

                # if the original mail was marked as spam do not send bounce 
message
                :0
                * ^X-Spam-Status: Yes
                {
LOG=`date`": sending of bounce message to ${ORIGINALSENDER} was skipped because the original message was marked as spam.${NL}"
                        :0
                        /dev/null
                }

                :0 c:
                bouncetemp.${BOUNCEPID}

                :0
                | ( formail -rt \
                        -I"From: $DAEMON (Mail Delivery Subsystem)" \
                        -I"Subject: Returned mail: see transcript for details" \
                        -I"Auto-Submitted: auto-generated (failure)" \
                        -I"MIME-Version: 1.0" \
                        -I"Errors-To: <>" \
-I"Content-Type: multipart/report; report-type=delivery-status; boundary=${DQ}${MIMEBREAK}${DQ}" \
                        -A"X-Loop: ${DAEMON}";\
                        printf "\nThis is a MIME-encapsulated message\n";\
                        printf "\n--%s\n\n" "${MIMEBREAK}";\
                        printf "The original message was received at %s" 
"${DATE}";\
                        printf " from %s\n" "${ORIGINALSENDER}";\
printf "\n----- The original mail could not be deliverd to the following addresses due to a temporary error -----";\ printf "\n\n451 Temporary local deliveriy problem for %s - please try again later... \n" "${LOCALRECIPIENT}";\ printf "\n--%s\nContent-Type: message/delivery-status\n\n" "$ {MIMEBREAK}";\
                        printf "Reporting-MTA: dns; %s\n" "[EMAIL PROTECTED]";\
                        printf "Arrival-Date: %s\n\n" "${DATE}";\
                        printf "Final-Recipient: RFC822; %s\n" 
"${LOCALRECIPIENT}";\
                        printf "Last-Attempt-Date: %s\n" "`date`";\
                        printf "\n--%s\nContent-Type: message/rfc822\n\n" 
"${MIMEBREAK}";\
                        cat bouncetemp.${BOUNCEPID};\
                        printf "\n--%s--\n\n" "${MIMEBREAK}";\
                        rm -f bouncetemp.${BOUNCEPID} \
                ) | ${SENDMAIL} -od -t
        }
}

--
dbap GmbH - one-stop e-business
phone +49 251 609979-0 / fax +49 251 609979-99
Martin-Luther-King Weg 20 - 48155 Muenster, Germany
http://www.dbap.de

Die dbap GmbH ist Full-Service Dienstleister für mittelständische
Unternehmen. Wir betreuen die Einbindung modernster E-Business-
Technologien in die bestehenden Geschäftsprozesse auf Basis der
hauseigenen Softwareplattform dStore SmartSuite.

dbap GmbH, Sitz: Münster HRB 5891, Amtsgericht Münster
Geschäftsführer: Björn Dolkemeier, Stefan Goebel

Reply via email to