This post was published back in 2008. It may not function as originally intended or may be missing images.
How to Block Email From a Specific Address on a Cpanel/WHM or Other Web Server Using Exim
While working on a client project that had a mass member email function, I needed a way to test the system exactly as it would run in production. This meant, when it ran, it would send emails to all of the members in the directory instead of a test email address. The only problem was I didn't want to send test emails out to the thousands of members in the directory.
So I wanted a way have PHP still send the email out as it normally would but have the mail server (EXIM) kill it before it left the server.
Luckily this is very easy to do. With EXIM, you can setup filters that can perform a large number of tasks, like blocking message, or blind copying messages to other email addresses. In this case, I'm going to create a filter to cause an email coming from a specific sender to fail (the email address I use to send the email in PHP).
What you'll want to do is find your System Filter File for EXIM. In WHM, you can find this file listed in your EXIM Configuration Editor about half way down the page.
Once you've located the file, log into SSH and edit the file.
if first_delivery and ( ("$h_from:" contains "emailtoblock@mydomain.com") ) then fail endif
if first_delivery and ( ("$h_from:" contains "emailtoblock@mydomain.com") ) then unseen deliver "youremail@yourdomain.com" fail endif
Where I Learned This: I found the solution the Imthiaz Blog and the Exim Documentation.