FYI I’m currently using this, though a filter would be more elegant.
add_filter( 'wp_mail', 'filter_wp_mail' );
function filter_wp_mail( $args ) {
// Check backtrace
$backtrace = debug_backtrace();
foreach ( $backtrace as $item ) :
// Is this filter is being applied by wpMandrill::wp_mail_native()?
if ( ! empty( $item['class'] ) && $item['class'] == 'wpMandrill' &&
! empty( $item['function'] ) && $item['function'] == 'wp_mail_native' ) :
// If so, abort email
$args['to'] = array();
endif;
endforeach;
return $args;
}
Hi @gyrus , the cleanest way we saw to do this was to wrap the wp_mail_native function from the plugin in an ‘action’. You can now just add a ‘remove_action’ function on your site in order to prevent the native wp_mail function from running when this plugin is active. See the pull request for more details. Thanks!
https://github.com/Miller-Media/send-emails-with-mandrill/pull/13