Difference between revisions of "Exim Queue Scripts"
(→Advanced message delete based on address) |
|||
| Line 23: | Line 23: | ||
find /var/spool/exim/input -name '*-H' | xargs grep 'auth_id' | grep <EMAIL ADDRESS> | cut -d: -f1 | cut -d/ -f7 | cut -d- -f1-3 | xargs exim -Mrm | find /var/spool/exim/input -name '*-H' | xargs grep 'auth_id' | grep <EMAIL ADDRESS> | cut -d: -f1 | cut -d/ -f7 | cut -d- -f1-3 | xargs exim -Mrm | ||
</code> | </code> | ||
| − | + | for dir in $(ls -l /var/spool/exim/input/ | grep -v "\." | awk '{print $9}'); | |
| + | do echo "Cleaning up $dir"; | ||
| + | echo "Getting emails in directory"; | ||
| + | email=`find /var/spool/exim/input/$dir -name '*-H'`; | ||
| + | ecount=`echo "$email" | wc -l`; | ||
| + | echo "Found $ecount messages"; | ||
| + | spam=`echo "$email" | xargs grep 'Subject: Delivery Status Notification' | cut -d: -f1 | cut -d- -f1-3;` | ||
| + | scount=`echo "$spam" | wc -l`; | ||
| + | echo "Found $scount spam messages"; | ||
| + | echo "Deleting"; | ||
| + | for email in $(echo "$spam" | rev | cut -d "/" -f1 | rev); | ||
| + | do exim -Mrm $email; | ||
| + | done; | ||
| + | done; | ||
===Advanced sender find=== | ===Advanced sender find=== | ||
Makes it easier to identify spamming accounts with large exim queues | Makes it easier to identify spamming accounts with large exim queues | ||
| Line 54: | Line 67: | ||
echo "Deleting"; | echo "Deleting"; | ||
echo "$spam" | xargs exim -Mrm; | echo "$spam" | xargs exim -Mrm; | ||
| + | done; | ||
| + | </code> | ||
| + | |||
| + | ===Advanced NDR delete=== | ||
| + | Removes Delivery Status Notifications per mail queue | ||
| + | <code>[bash,n] | ||
| + | for dir in $(ls -l /var/spool/exim/input/ | grep -v "\." | awk '{print $9}'); | ||
| + | do echo "Cleaning up $dir"; | ||
| + | echo "Getting emails in directory"; | ||
| + | email=`find /var/spool/exim/input/$dir -name '*-H'`; | ||
| + | ecount=`echo "$email" | wc -l`; | ||
| + | echo "Found $ecount messages"; | ||
| + | spam=`echo "$email" | xargs grep 'Subject: Delivery Status Notification' | cut -d: -f1 | cut -d- -f1-3;` | ||
| + | scount=`echo "$spam" | wc -l`; | ||
| + | echo "Found $scount spam messages"; | ||
| + | echo "Deleting"; | ||
| + | for email in $(echo "$spam" | rev | cut -d "/" -f1 | rev); | ||
| + | do exim -Mrm $email; | ||
| + | done; | ||
done; | done; | ||
</code> | </code> | ||
==What to change== | ==What to change== | ||
Revision as of 19:39, 8 November 2011
Contents
- 1 Overview
- 2 Script
- 2.1 Find top sending addresses for current messages in queue
- 2.2 Get message IDs for messages from a specific sender
- 2.3 Get list of IP addresses sending messages from specific address
- 2.4 Delete messages based on address
- 2.5 Advanced sender find
- 2.6 Advanced message delete based on address
- 2.7 Advanced NDR delete
- 3 What to change
Overview
Different scripts to search the exim queue.
Script
Find top sending addresses for current messages in queue
[bash,n]
find /var/spool/exim/input -name '*-H' | xargs grep 'auth_id' | cut -d " " -f2 | sort | uniq -c | sort -rn
Get message IDs for messages from a specific sender
[bash,n]
find /var/spool/exim/input -name '*-H' | xargs grep 'auth_id' | grep <EMAIL ADDRESS> | cut -d: -f1 | cut -d/ -f7 | cut -d- -f1-3
Get list of IP addresses sending messages from specific address
[bash,n]
for i in $(find /var/spool/exim/input -name '*-H' | xargs grep 'auth_id' | grep <EMAIL ADDRESS> | cut -d: -f1 | cut -d/ -f7 | cut -d- -f1-3);
do exim -Mvh $i | grep helo | cut -d "[" -f2 | cut -d "]" -f1| grep -v helo_name; done | sort | uniq -c | sort -n
Delete messages based on address
[bash,n]
find /var/spool/exim/input -name '*-H' | xargs grep 'auth_id' | grep <EMAIL ADDRESS> | cut -d: -f1 | cut -d/ -f7 | cut -d- -f1-3 | xargs exim -Mrm
for dir in $(ls -l /var/spool/exim/input/ | grep -v "\." | awk '{print $9}');
do echo "Cleaning up $dir";
echo "Getting emails in directory";
email=`find /var/spool/exim/input/$dir -name '*-H'`;
ecount=`echo "$email" | wc -l`;
echo "Found $ecount messages";
spam=`echo "$email" | xargs grep 'Subject: Delivery Status Notification' | cut -d: -f1 | cut -d- -f1-3;`
scount=`echo "$spam" | wc -l`;
echo "Found $scount spam messages";
echo "Deleting";
for email in $(echo "$spam" | rev | cut -d "/" -f1 | rev);
do exim -Mrm $email;
done;
done;
Advanced sender find
Makes it easier to identify spamming accounts with large exim queues
[bash,n]
for dir in $(ls -l /var/spool/exim/input/ | grep -v "\." | awk '{print $9}');
do echo "Searching $dir directory";
echo "Getting emails in directory";
email=`find /var/spool/exim/input/$dir -name '*-H'`;
ecount=`echo "$email" | wc -l`;
if $email != "" ;
then
echo -e "\e[0;31mFound $ecount messages\e[0m";
echo "$email" | xargs grep 'auth_id' | cut -d " " -f2 | sort | uniq -c | sort -rn;
fi;
done;
Advanced message delete based on address
Makes it easier to delete messages in large spam queues
[bash,n]
for dir in $(ls -l /var/spool/exim/input/ | grep -v "\." | awk '{print $9}');
do echo "Cleaning up $dir";
echo "Getting emails in directory";
email=`find /var/spool/exim/input/$dir -name '*-H'`;
ecount=`echo "$email" | wc -l`;
echo "Found $ecount messages";
spam=`echo "$email" | xargs grep 'auth_id' | grep <EMAIL ADDRESS> | cut -d: -f1 | cut -d- -f1-3;`
scount=`echo "$spam" | wc -l`;
echo "Found $scount spam messages";
echo "Deleting";
echo "$spam" | xargs exim -Mrm;
done;
Advanced NDR delete
Removes Delivery Status Notifications per mail queue
[bash,n]
for dir in $(ls -l /var/spool/exim/input/ | grep -v "\." | awk '{print $9}');
do echo "Cleaning up $dir";
echo "Getting emails in directory";
email=`find /var/spool/exim/input/$dir -name '*-H'`;
ecount=`echo "$email" | wc -l`;
echo "Found $ecount messages";
spam=`echo "$email" | xargs grep 'Subject: Delivery Status Notification' | cut -d: -f1 | cut -d- -f1-3;`
scount=`echo "$spam" | wc -l`;
echo "Found $scount spam messages";
echo "Deleting";
for email in $(echo "$spam" | rev | cut -d "/" -f1 | rev);
do exim -Mrm $email;
done;
done;