You are here

function amazon_ses_admin_settings_submit in Amazon SES 6

Submission 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.

1 string reference to 'amazon_ses_admin_settings_submit'
amazon_ses_admin_settings in ./amazon_ses.admin.inc
Administrative settings.

File

./amazon_ses.admin.inc, line 126
Administrative forms for Amazon SES module.

Code

function amazon_ses_admin_settings_submit($form, &$form_state) {
  $values = $form_state['values'];

  // If an address was given, send a test email message.
  $test_address = $values['amazon_ses_test_address'];
  if ($test_address != '') {
    global $language;

    // Clear the variable so only one message is sent.
    variable_del('amazon_ses_test_address');
    $params['subject'] = t('Drupal Amazon SES test email');
    $params['body'] = $values['amazon_ses_test_body'];
    drupal_mail('amazon_ses', 'amazon-ses-test', $test_address, $language, $params);
    drupal_set_message(t('A test email has been sent to @email.', array(
      '@email' => $test_address,
    )));
  }
  if ($values['amazon_ses_on']) {
    variable_set('smtp_library', drupal_get_filename('module', 'amazon_ses'));
    drupal_set_message(t('Amazon SES will be used to deliver all site e-mails.'));
    watchdog('amazon-ses', 'Aamazon SES has been enabled.');
  }
  else {
    variable_del('smtp_library');
    drupal_set_message(t('Amazon SES has been disabled.'));
    watchdog('amazon-ses', 'Amazon SES has been disabled.');
  }
}