#!/bin/bash # created by henry saptono # this script will delete email with contain keyword 'viagra' # your email system must be based on qmailtoaster if [ -z "$1" ]; then echo "Usage: $0 [username]" exit 1 fi SIN="/home/vpopmail/domains/$1" if [ ! -d "$SIN" ]; then echo "Failed: Domain $1 Not Found" exit 2 fi if [ -n "$2" ]; then SIN="/home/vpopmail/domains/$1/$2" if [ ! -d "$SIN" ]; then echo "Failed: User $2 Not Found" exit 3 fi fi for x in `find $SIN -type f -iname "*mail*" `; do grep -i viagra $x && rm -f $x && echo "Email message $x Deleted"; done;