Drupal - How can I stop Drupal from sending e-mails of any kind?

As another, quicker, option, you can add the following lines to your site's settings.php file (if you have the Devel module installed, which you certainly should if this is a dev site).

$conf['mail_system'] = array(
  'default-system' => 'DevelMailLog',
);

That will replace the default mail system with Devel's development mail system, which writes emails to a file log rather than sending them to a recipient. By default the files are stored in temporary://devel-mails, but you can alter that by setting another variable, eg.

$conf['devel_debug_mail_directory'] = '/path/to/folder';

Just a note to add another module to the "There is a module for that" list :

Reroute email intercepts all outgoing emails from a Drupal site and reroutes them to a predefined configurable email address.

I agree that this functionnality can easily be implemented with a few lines of code, but using this module, you could continue to receive emails to a predefined adress, with details on the original recipient, nice functionnality imho.


Or you can use hook_mail_alter to redirect or prevent drupal mails:

/**
* Implements hook_mail_alter
*/
function yourmodule_mail_alter(&$message) {
  // set 'To' field to nothing, so Drupal won’t have any address
  $message['to'] = ''; 
}

Tags:

Staging

Emails