Send email with list of active plugins upon activation/deactivation

If you look here in /wp-admin/includes/plugin.php

        do_action( 'deactivated_plugin', $plugin, $network_deactivating );
    }
}

if ( $do_blog )
    update_option('active_plugins', $current);
if ( $do_network )
    update_site_option( 'active_sitewide_plugins', $network_current );

The options aren’t updated until after the hook fires.

You can get around this by using the first parameter to deactivated_plugin:

function detect_plugin_change( $plugin, $network_activation ) {

    $url = urlToDomain(site_url());

    $the_plugs = get_option('active_plugins'); 
    sort ( $the_plugs );
    foreach($the_plugs as $value) {
        // Skip the deactivated plugin.
        if ( $plugin === $value ) {
            continue;
        }

        $string = explode("https://wordpress.stackexchange.com/",$value);
        $plugins .= $string[0] .", ";
    }

    $to = [email address removed];
    $subject = $url;
    $body = $plugins;
    $headers = array('Content-Type: text/html; charset=UTF-8');

    wp_mail( $to, $subject, $body, $headers );

}

Edit: You can also get “fancy” and provide more details about the plugins, if needed, using get_plugin_data.