Tommi Lätti wrote:
I've been using dspam quite successfully for a year now, but I've come to think if it would be possible to take this integration to a next level, using public and spam folders.

All users currently use the webpage to manage their spamquarantine and honestly, I'd like to partially get rid of that.

So, I was thinking of a function which could grab, lets say 1/hour, all messages from a public folder and feed them to dspam (using smtp).

Are there any scripts readily available that can pull a single mailbox and then feed it? The same thing could be used of course to feed back innocent messages.

I use the following script in the way you mention. Fill in the variables between the ## ## below to match your system setup and set to run from Cron.

If anyone has any suggestions for improvements feel free to add them

Carl.
www.adepteo.net

#!/bin/sh
export PATH=$PATH:/usr/local/bin

MYSQL_CMD="/usr/local/mysql/bin/mysql -h ##SERVERNAME## -u##USERNAME## -p##PASSWORD## dbmail -B -N -r"
#Grab Messages
HAM_MSG_UIDS=`$MYSQL_CMD -e "SELECT dbmail_messages.message_idnr FROM dbmail_messages WHERE dbmail_messages.mailbox_idnr='##ID NUMBER FOR FOLDER##' and status='0'"` SPAM_MSG_UIDS=`$MYSQL_CMD -e "SELECT dbmail_messages.message_idnr FROM dbmail_messages WHERE dbmail_messages.mailbox_idnr='##ID NUMBER FOR FOLDER##' and deleted_flag='0'"`



#
#   [EMAIL PROTECTED] is just a valid user ID - nothing else
#

for MSG_UID in $HAM_MSG_UIDS
do
{
       echo ${MSG_UID}
$MYSQL_CMD -e "SET group_concat_max_len=2048;SELECT GROUP_CONCAT(dbmail_messageblks.messageblk
ORDER BY dbmail_messageblks.is_header DESC SEPARATOR '') FROM
dbmail_messages JOIN dbmail_messageblks ON
(dbmail_messages.physmessage_id=dbmail_messageblks.physmessage_id) WHERE
dbmail_messages.message_idnr='${MSG_UID}' GROUP BY
dbmail_messages.message_idnr" | /opt/dspam/bin/dspam --user [EMAIL PROTECTED] --class=innocent --source=
error --stdout
$MYSQL_CMD -e "UPDATE dbmail_messages SET deleted_flag='1', status='2' WHERE message_idnr='${MSG_UI
D}'";
}
done

for MSG_UID in $SPAM_MSG_UIDS
do
{
       echo ${MSG_UID}
$MYSQL_CMD -e "SET group_concat_max_len=2048;SELECT GROUP_CONCAT(dbmail_messageblks.messageblk
ORDER BY dbmail_messageblks.is_header DESC SEPARATOR '') FROM
dbmail_messages JOIN dbmail_messageblks ON
(dbmail_messages.physmessage_id=dbmail_messageblks.physmessage_id) WHERE
dbmail_messages.message_idnr='${MSG_UID}' and dbmail_messageblks.is_header=1 GROUP BY dbmail_messages.message_idnr" | /opt/dspam/bin/dspam --user [EMAIL PROTECTED] --class=spam --source=erro
r --stdout
$MYSQL_CMD -e "UPDATE dbmail_messages SET deleted_flag='1', status='2' WHERE message_idnr='${MSG_UI
D}'";
}
done

Reply via email to