You are here

function phpmailer_settings_form_submit in PHPMailer 6.2

Same name and namespace in other branches
  1. 5.2 phpmailer.admin.inc \phpmailer_settings_form_submit()
  2. 6.3 phpmailer.admin.inc \phpmailer_settings_form_submit()
  3. 7.4 phpmailer.admin.inc \phpmailer_settings_form_submit()
  4. 7.3 phpmailer.admin.inc \phpmailer_settings_form_submit()

Form submit function.

See also

phpmailer_settings_form()

1 string reference to 'phpmailer_settings_form_submit'
phpmailer_settings_form in ./phpmailer.admin.inc
Form builder for both the Mime Mail settings and our own settings page.

File

./phpmailer.admin.inc, line 180
Administrative functions for PHPMailer integration module.

Code

function phpmailer_settings_form_submit($form, &$form_state) {

  // Enable/disable mail sending subsystem.
  if ($form_state['values']['smtp_on']) {
    if (!phpmailer_enabled()) {
      variable_set('smtp_library', drupal_get_filename('module', 'phpmailer'));
      drupal_set_message(t('PHPMailer will be used to deliver all site e-mails.'));
      watchdog('phpmailer', 'PHPMailer has been enabled.');
    }
  }
  else {
    if (phpmailer_enabled()) {
      variable_del('smtp_library');
      drupal_set_message(t('PHPMailer has been disabled.'));
      watchdog('phpmailer', 'PHPMailer has been disabled.');
    }
  }

  // Log configuration changes.
  $settings = array(
    'host',
    'port',
    'protocol',
    'username',
  );

  // Ignore empty passwords if hide password is active.
  if (variable_get('smtp_hide_password', 0) && $form_state['values']['smtp_password'] == '') {
    unset($form_state['values']['smtp_password']);
  }
  else {
    $settings[] = 'password';
  }
  foreach ($settings as $setting) {
    if ($form_state['values']['smtp_' . $setting] != variable_get('smtp_' . $setting, '')) {
      watchdog('phpmailer', 'SMTP configuration changed.');
      break;
    }
  }
}