You are here

function smtp_admin_provider_settings_validate in SMTP Authentication Support 7.2

Validation for the administrative settings form.

Parameters

form: An associative array containing the structure of the form.

form_state: A keyed array containing the current state of the form.

File

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

Code

function smtp_admin_provider_settings_validate($form, &$form_state) {
  if ($form_state['values']['smtp_port'] == '') {
    form_set_error('smtp_port', t('You must enter a SMTP port number.'));
  }
  if ($form_state['values']['name'] == '') {
    form_set_error('name', t('You must enter a machine name.'));
  }
  if ($form_state['values']['name'] == 'new') {
    form_set_error('name', t("The machine name must not be 'new'."));
  }
  if ($form_state['values']['name'] == 'none') {
    form_set_error('name', t("The machine name must not be 'none'."));
  }
  if ($form_state['values']['smtp_from'] && !valid_email_address($form_state['values']['smtp_from'])) {
    form_set_error('smtp_from', t('The provided from e-mail address is not valid.'));
  }

  // 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']);
  }
}