You are here

function smtp_admin_settings_form_submit in SMTP Authentication Support 7

Same name and namespace in other branches
  1. 7.2 smtp.admin.inc \smtp_admin_settings_form_submit()

Submit handler().

1 string reference to 'smtp_admin_settings_form_submit'
smtp_admin_settings in ./smtp.admin.inc
Administrative settings.

File

./smtp.admin.inc, line 293
Administrative page code for the smtp module.

Code

function smtp_admin_settings_form_submit($form, &$form_state) {

  // Check if SMTP status has been changed.
  if (!variable_get('smtp_on', FALSE) && $form_state['values']['smtp_on'] || variable_get('smtp_on', FALSE) && !$form_state['values']['smtp_on']) {
    $mail_modes = variable_get('mail_system', array(
      'default-system' => 'DefaultMailSystem',
    ));

    // Turning on.
    if ($form_state['values']['smtp_on']) {
      variable_set('smtp_previous_mail_system', $mail_modes['default-system']);
      $mail_modes['default-system'] = 'SmtpMailSystem';
    }
    else {
      $mail_modes['default-system'] = variable_get('smtp_previous_mail_system', 'DefaultMailSystem');
    }
    variable_set('mail_system', $mail_modes);
  }

  // If username is set empty, we must set both username/password empty as well.
  if (empty($form_state['values']['smtp_username'])) {
    $form_state['values']['smtp_password'] = '';
  }
  elseif (empty($form_state['values']['smtp_password'])) {
    unset($form_state['values']['smtp_password']);
  }

  // Save the test address to send an email after all the settings have been
  // updated.
  $form_state['storage']['smtp']['smtp_test_address'] = $form_state['values']['smtp_test_address'];
  unset($form_state['values']['smtp_test_address']);
}