'textfield', '#title' => t('Sender name'), '#default_value' => variable_get('mimemail_name', variable_get('site_name', 'Drupal')), '#size' => 60, '#maxlength' => 128, '#description' => t('The name that all site emails will be from when using default engine.'), ); $form['mimemail']['mimemail_mail'] = array( '#type' => 'textfield', '#title' => t('Sender e-mail address'), '#default_value' => variable_get('mimemail_mail', variable_get('site_mail', ini_get('sendmail_from'))), '#size' => 60, '#maxlength' => 128, '#description' => t('The email address that all site e-mails will be from when using default engine.'), ); $form['mimemail']['mimemail_alter'] = array( '#type' => 'checkbox', '#title' => t('Use as default mail system.'), '#default_value' => variable_get('mimemail_alter', FALSE), '#description' => t('Use mime mail system to deliver all site messages. With this option, all emails will have styles and formatting.'), ); $form['mimemail']['mimemail_simple_address'] = array( '#type' => 'checkbox', '#title' => t('Use simple address format'), '#default_value' => variable_get('mimemail_simple_address', FALSE), '#description' => t('Use the simple format of user@example.com for all email addresses.'), ); $form['mimemail']['mimemail_sitestyle'] = array( '#type' => 'checkbox', '#title' => t('Include site style sheets'), '#default_value' => variable_get('mimemail_sitestyle', TRUE), '#description' => t('Gather all style sheets when no mail.css found in the default theme directory.'), '#disabled' => $disable_sitestyle, ); $form['mimemail']['mimemail_textonly'] = array( '#type' => 'checkbox', '#title' => t('Send plain text email only'), '#default_value' => variable_get('mimemail_textonly', FALSE), '#description' => t('This option disables the use of email messages with graphics and styles. All messages will be converted to plain text.'), ); // Get a list of all formats. $formats = filter_formats(); foreach ($formats as $format) { $format_options[$format->format] = $format->name; } $form['mimemail']['mimemail_format'] = array( '#type' => 'select', '#title' => t('E-mail format'), '#options' => $format_options, '#default_value' => variable_get('mimemail_format'), '#access' => count($formats) > 1, '#attributes' => array('class' => array('filter-list')), ); $form['mimemail']['advanced'] = array( '#type' => 'fieldset', '#title' => t('Advanced settings'), '#collapsible' => TRUE, '#collapsed' => TRUE, ); $form['mimemail']['advanced']['mimemail_incoming'] = array( '#type' => 'checkbox', '#title' => t('Process incoming messages posted to this site'), '#default_value' => variable_get('mimemail_incoming', FALSE), '#description' => t('This is an advanced setting that should not be enabled unless you know what you are doing.'), ); $form['mimemail']['advanced']['mimemail_key'] = array( '#type' => 'textfield', '#title' => t('Message validation string'), '#default_value' => variable_get('mimemail_key', md5(rand())), '#required' => TRUE, '#description' => t('This string will be used to validate incoming messages. It can be anything, but must be used on both sides of the transfer.'), ); // Get the available mail engines. $engines = mimemail_get_engines(); foreach ($engines as $module => $engine) { $engine_options[$module] = $engine['name'] . ': ' . $engine['description']; } // Hide the settings if only 1 engine is available. if (count($engines) == 1) { variable_set('mimemail_engine', key($engines)); $form['mimemail']['engine'] = array( '#type' => 'hidden', '#value' => variable_get('mimemail_engine', 'mimemail'), ); } else { $form['mimemail']['engine'] = array( '#type' => 'select', '#title' => t('E-mail engine'), '#default_value' => variable_get('mimemail_engine', 'mimemail'), '#options' => $engine_options, '#description' => t('Choose an engine for sending mails from your site.'), ); } if (variable_get('mimemail_engine', 'mail')) { $settings = module_invoke(variable_get('mimemail_engine', 'mimemail'), 'mailengine', 'settings'); if ($settings) { $form['mimemail']['engine_settings'] = array( '#type' => 'fieldset', '#title' => t('Engine specific settings'), ); foreach ($settings as $name => $value) { $form['mimemail']['engine_settings'][$name] = $value; } } } else { drupal_set_message(t('Please choose a mail engine.'), 'error'); } $form['#submit'][] = 'mimemail_admin_settings_form_submit'; return system_settings_form($form); } /** * Handle submission of the configuration form. */ function mimemail_admin_settings_form_submit($form, &$form_state) { $mail_system = variable_get('mail_system', array('default-system' => 'DefaultMailSystem')); $default_system = $mail_system['default-system']; $mimemail_alter = $form_state['values']['mimemail_alter']; // Set as default mail system if Mime Mail is chosen to handle all mail. if ($mimemail_alter && $default_system != 'MimeMailSystem') { $default_system = 'MimeMailSystem'; } elseif (!$mimemail_alter && $default_system == 'MimeMailSystem') { $default_system = 'DefaultMailSystem'; } $mail_system['default-system'] = $default_system; variable_set('mail_system', $mail_system); }