How can I remove the remains of the Mass Contact module not properly uninstalled? I tried the Drupal 8 version of the Mass Contact module (8.x-1.0-beta2, released on June 2017).  

As I was not fully satisfied, I decided to uninstall it.
Once done, I got errors when I tried editing a user account. 


  The website encountered an unexpected error. Please try again later.
  Error: Call to undefined function mass_contact_opt_out_allowed_values_callback() in options_allowed_values() (line 89 of core/modules/options/options.module).


Digging a little bit, I found that the code to uninstall the module was not fully implemented: it leaves (at least) two configurations (field.field.user.user.mass_contact_opt_out and field.storage.user.mass_contact_opt_out) and a table in the database (d8_user__mass_contact_opt_out).  

How can I get rid of that and have a clean uninstall?
This is an issue already resolved for the 8.x-1.x branch, as reported in Uninstall should remove mass_contact_opt_out field.

The code that has been added to the uninstall hook is the following one.

Drupal::configFactory()-&gt;getEditable('field.field.user.user.mass_contact_opt_out')-&gt;delete();
Drupal::configFactory()-&gt;getEditable('field.storage.user.mass_contact_opt_out')-&gt;delete();


If you have Drush installed, you can write those two lines in a file (for example, fix-module.php) and run it with drush php-script fix.module.php. You can also put the following code in a file next to the authorize.php file that comes with Drupal core, and access that file from the browser.

use Drupal\Core\DrupalKernel;
use Drupal\Core\Config\ConfigFactoryInterface;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

// Change the directory to the Drupal root.
chdir('..');
$autoloader = (require_once 'autoload.php');

try {
  $request = Request::createFromGlobals();
  $kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
  $kernel-&gt;boot();
  Drupal::configFactory()-&gt;getEditable('field.field.user.user.mass_contact_opt_out')-&gt;delete();
    Drupal::configFactory()-&gt;getEditable('field.storage.user.mass_contact_opt_out')-&gt;delete();
} catch (HttpExceptionInterface $e) {
  $response = new Response('', $e-&gt;getStatusCode());
  $response-&gt;prepare($request)-&gt;send();
  exit;
}