You are here

function swiftmailer_admin_transport_form_submit in Swift Mailer 7

Form submission handler for swiftmailer_admin_transport_form().

File

includes/pages/swiftmailer_admin_transport.inc, line 253
An administration page which allows for configuration of transport types.

Code

function swiftmailer_admin_transport_form_submit($form, &$form_state) {
  if (isset($form_state['values']['transport']['type'])) {
    variable_set('swiftmailer_transport', $form_state['values']['transport']['type']);
    switch ($form_state['values']['transport']['type']) {
      case SWIFTMAILER_TRANSPORT_SMTP:
        variable_set('swiftmailer_smtp_host', $form_state['values']['transport']['configuration'][SWIFTMAILER_TRANSPORT_SMTP]['server']);
        variable_set('swiftmailer_smtp_port', $form_state['values']['transport']['configuration'][SWIFTMAILER_TRANSPORT_SMTP]['port']);
        variable_set('swiftmailer_smtp_encryption', $form_state['values']['transport']['configuration'][SWIFTMAILER_TRANSPORT_SMTP]['encryption']);
        variable_set('swiftmailer_smtp_username', $form_state['values']['transport']['configuration'][SWIFTMAILER_TRANSPORT_SMTP]['username']);
        variable_set('swiftmailer_smtp_password', $form_state['values']['transport']['configuration'][SWIFTMAILER_TRANSPORT_SMTP]['password']);
        drupal_set_message(t('Drupal has been configured to send all e-mails using the SMTP transport type.'), 'status');
        break;
      case SWIFTMAILER_TRANSPORT_SENDMAIL:
        variable_set('swiftmailer_sendmail_path', $form_state['values']['transport']['configuration'][SWIFTMAILER_TRANSPORT_SENDMAIL]['path']);
        variable_set('swiftmailer_sendmail_mode', $form_state['values']['transport']['configuration'][SWIFTMAILER_TRANSPORT_SENDMAIL]['mode']);
        drupal_set_message(t('Drupal has been configured to send all e-mails using the Sendmail transport type.'), 'status');
        break;
      case SWIFTMAILER_TRANSPORT_NATIVE:
        drupal_set_message(t('Drupal has been configured to send all e-mails using the PHP transport type.'), 'status');
        break;
      case SWIFTMAILER_TRANSPORT_SPOOL:
        variable_set('swiftmailer_spool_directory', $form_state['values']['transport']['configuration'][SWIFTMAILER_TRANSPORT_SPOOL]['directory']);
        drupal_set_message(t('Drupal has been configured to send all e-mails using the Spool transport type.'), 'status');
        break;
    }
  }
}