Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Steve Taylor

    (@gyrus)

    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;
    
    }
    Plugin Author Matt Miller

    (@millermedianow)

    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

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘stop fallback to native wp_mail()’ is closed to new replies.