In the course of my Linux administrative duties (on a cPanel server), I have created multiple scripts to help us out with Exim, our mail transfer agent. These are mostly used to help us fight spam, and determine who is spamming when it occurs.
This monitors the number of emails in the queue, and sends ours admins an email when a limit (1000) is reached. It would need to be run on a schedule (via cron).
#!/bin/bashexport AdminEmailList="ADMIN EMAIL LIST SEPARATED BY COMMAS HERE"export Num=`/usr/sbin/exim -bpc`if [ $Num-gt 1000 ];thenecho"Too many emails! $Num"| /usr/sbin/sendmail -v "$AdminEmailList"#Here might be a good place to delete emails with “undeliverable” strings within them#Example (See the 3rd script): exim-delete-messages-with 'A message that you sent could not be delivered'fi
This deletes any emails in the queue from or to a specified email address (first parameter). If the address is the recipient, the from must be "<>" (root)
To add comments, please go to the forum page for this post (guest comments are allowed for the Projects, Posts, and Updates Forums). Comments are owned by the user who posted them. We accept no responsibility for the contents of these comments.