I would probably approach this with a wp_mail
filter to catch these messages before they are sent. That would be the simplest approach in my opinion.
You could create a filter function to screen email content and use key elements unique to these emails. My example will just target "New comment on your post" contained in the body, although you may want to fine tune and use additional text.
We'll also compare the email address the message is going to. I'm going to use the address stored in the db as the site's admin email. If you have a different address, you'll want to change this.
add_filter( 'wp_mail', 'my_wp_mail_filter' );
function my_wp_mail_filter( $args ) {
// Get the site admin email.
$admin_email = get_option( 'admin_email' );
// What string are we looking for in the body?
$needle = "New comment on your post";
// Is this a new comment notification email?
// Check for "New comment on your post" in body of message.
if ( strpos( $args['message'], $needle ) ) {
// If this is a new comment notification, who is it going to?
// Check to see if the "to" address is not the admin.
if ( $args['to'] != $admin_email ) {
// This message is going to someone OTHER THAN the admin.
// Return an empty array (dump all content, so email fails).
return array();
}
}
// Otherwise return unfiltered (so process can continue).
return $args;
}