#!/bin/bash # report_spam_quarantine - Send email to each user with unexamined quarantined email. # Steve Pellegrin (spellegrin at convoglio dot com) # # History: # 1.0 2005-January-1 Original code # 1.1 2005-February-3 Works with large, domain and standard # # Usage: # report_spam_quarantine DATA=~dspam/data # DSpam data directory ADMIN="steve" # Who should get the summary report email (empty for none) WEBUSER="apache" # Should match the user that runs the DSpam CGI TEMPFILE="/tmp/qTemp" # Used to construct message to send to ADMIN NOTIFYEXT=".notify" # File name extension for the notification file MESSAGESUBJ="You have Quarantined Email" # Subject line for user email messages MESSAGETXT=~dspam/quarantine.txt # File that contains the email message text # Remove old temp file, if any if [ -f ${TEMPFILE} ]; then rm ${TEMPFILE} fi # For each user mailbox... for mboxFile in `find ${DATA} -follow -name *mbox` do if [ -s $mboxFile ]; then # Extract the user name from the path # and generate the notification file name userPath="${mboxFile%/*}" user="${userPath##*/}" notificationFile="$userPath/$user${NOTIFYEXT}" # Send notification if the mailbox has changed since the last notification. if [ $mboxFile -nt $notificationFile ]; then mail -s "${MESSAGESUBJ}" "$user" <${MESSAGETXT} echo "$user has quarantined mail" >>${TEMPFILE} sudo -u ${WEBUSER} touch $notificationFile fi; fi; done # Send the report to the admin, if required. if [ -f ${TEMPFILE} ]; then if [ -n ${ADMIN} ]; then mail -s "Quarantine Report" ${ADMIN} <${TEMPFILE} fi; rm ${TEMPFILE} fi