Bounce processing is one thing which keeps failing in the Sai Inspires list. And if the bounces are not processed, more emails will get bounced due to Yahoo and others thinking that we're spamming, and that makes the whole thing a mess.
I have been manually checking at the eventlog in phplist for the bounce processing messages. But instead of that, thought I would write a script to automatically check if the bounces file is too large - it will be large if it has not been processed, and then the processing will continue to fail, so we have to flush the file and start retrieving fresh emails as given at
http://hnsws.blogspot.in/2011/04/bounce-processing-cleanup.html
So, have written a script to run as root cron, testbouncesfile.sh, with inspiration from this post, something like this:
CURRENT_DATE=`date +%Y-%m-%d' '%H:%M:%S`
find $FILE_TO_FLUSH -size +2k
while read file; do
echo "$file is too large = $(stat -c%s "$file") bytes, flushing it with rm and touch." > $MAIL_FILE
mail -s "Automatic Bounce message check at $CURRENT_DATE" -c $MAIL_COPY $MAIL_DESTINATION < $MAIL_FILE
rm $FILE_TO_FLUSH
touch $FILE_TO_FLUSH
chown therelevantmailaccount:mail $FILE_TO_FLUSH
chmod 660 $FILE_TO_FLUSH
done
The cron runs as root for the permissions required. I'd tested it with a dummy mail file which I tried making bigger / smaller etc. Today, 6 days after I made the script and put it in the cron, I got a mail from root with /var/mail/relevantfile is too large = 9209549 bytes, flushing it with rm and touch.
I have been manually checking at the eventlog in phplist for the bounce processing messages. But instead of that, thought I would write a script to automatically check if the bounces file is too large - it will be large if it has not been processed, and then the processing will continue to fail, so we have to flush the file and start retrieving fresh emails as given at
http://hnsws.blogspot.in/2011/04/bounce-processing-cleanup.html
So, have written a script to run as root cron, testbouncesfile.sh, with inspiration from this post, something like this:
CURRENT_DATE=`date +%Y-%m-%d' '%H:%M:%S`
find $FILE_TO_FLUSH -size +2k
while read file; do
echo "$file is too large = $(stat -c%s "$file") bytes, flushing it with rm and touch." > $MAIL_FILE
mail -s "Automatic Bounce message check at $CURRENT_DATE" -c $MAIL_COPY $MAIL_DESTINATION < $MAIL_FILE
rm $FILE_TO_FLUSH
touch $FILE_TO_FLUSH
chown therelevantmailaccount:mail $FILE_TO_FLUSH
chmod 660 $FILE_TO_FLUSH
done
The cron runs as root for the permissions required. I'd tested it with a dummy mail file which I tried making bigger / smaller etc. Today, 6 days after I made the script and put it in the cron, I got a mail from root with /var/mail/relevantfile is too large = 9209549 bytes, flushing it with rm and touch.
No comments:
Post a Comment