You are here

function phpmailer_disable in PHPMailer 7.4

Same name and namespace in other branches
  1. 5.2 phpmailer.module \phpmailer_disable()
  2. 6.3 phpmailer.module \phpmailer_disable()
  3. 6.2 phpmailer.module \phpmailer_disable()
  4. 7.3 phpmailer.install \phpmailer_disable()

Implements hook_disable().

File

./phpmailer.install, line 77
PHPMailer installation functions.

Code

function phpmailer_disable() {
  if (phpmailer_enabled()) {

    // Remove PHPMailer from all mail keys it is configured for.
    $mail_system = variable_get('mail_system', array(
      'default-system' => 'DefaultMailSystem',
    ));
    foreach ($mail_system as $key => $class) {
      if ($class == 'DrupalPHPMailer') {
        if ($key != 'default-system') {
          unset($mail_system[$key]);
        }
        else {
          $mail_system[$key] = 'DefaultMailSystem';
        }
      }
    }
    variable_set('mail_system', $mail_system);
    variable_del('smtp_on');
    drupal_set_message(t('PHPMailer has been disabled.'));
  }
  if (module_exists('mimemail') && variable_get('mimemail_engine', 'mimemail') == 'phpmailer') {
    variable_del('mimemail_engine');
    drupal_set_message(t('MimeMail e-mail engine has been reset to default.'), 'warning');
  }
  if (module_exists('mailsystem')) {
    mailsystem_clear(array(
      'phpmailer' => 'DrupalPHPMailer',
    ));
  }
}