Disable Mail

Categories

Component ID

1611974

Component name

Disable Mail

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Component created

Component changed

Component body

About

Disable Mail is a module which allows you to disable outgoing mail on your site. You can do this for all mail, or specify which modules this should apply to.

This works by providing a MailSystemInterface. A MailSystemInterface is a mail handler. This means that when any module or the system sends mail, this handler decides what to do. The default handler sends mail using PHPs mail functions while others store the mail in a log file. This handler simply does nothing and reports a success to the system.

Set Up

To enable this feature, the user needs to enable the module and then set their configuration in the settings.php file. Below are some examples of how to set these settings up. The basic idea is that we are setting a Drupal configuration variable that lists the various handlers Drupal and modules should use.

Here is an example of a setting in settings.php. This line can be added anywhere in that file.

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

The above settings sets the "mail_system" default to "DisableMail" (the MailSystemInterface included in this module).

You could also add a conditional arguement such as:

if ($_SERVER['HTTP_HOST'] === "example.com") {
  $conf['mail_system'] = array(
    'default-system' => 'DefaultMailSystem',
    'example_module' => 'DisableMail',
  );
}

In this example, we check for the HTTP host and set a special mail handling setup for that server. In this case, the default mail handling is used everywhere but for the example_module module where mail is disabled.

See here for more information about how these module specific settings can work.

Who is this for?

This module requires the user to modify their settings.php file. This is something most users will have to do, but if you aren't familiar at all with PHP, you will have a challenging time setting up the logic to disable only certain modules on certain servers. Hopefully the documentation above helps you out since you should be able to fill in / replace the values.