No problemo.
If you don’t need any emails to be sent from WordPress you can stop all emails with a plugin like this:
If you need to stop individual emails, this is a bit of a hack I guess but I believe you can set the “To” email address to empty, or any invalid email address, in the wp_mail
hook. I haven’t used this a lot so you’d probably need to test this, here’s an example:
//set the email subject to something easy to catch
add_filter( 'bdpwr_code_email_subject' , function( $subject ) {
return 'no-send';
}, 10 , 1 );
//catch emails with this subject and set the "To" address to empty
add_filter( 'wp_mail' , function( $args ) {
if( $args['subject'] === 'no-send' ) {
$args['to'] = false;
}
return $args;
}, 10 , 2 );
Again, not tested, and a bit of a hack, but if this works for you for now I’ll close this and raise a ticket on GitHub for it, if not, I’ll try and do something sooner.
Let me know if it works for you either way!