You are here

function phpmailer_form_mimemail_admin_settings_alter in PHPMailer 8.3

Same name and namespace in other branches
  1. 6.3 phpmailer.module \phpmailer_form_mimemail_admin_settings_alter()
  2. 6.2 phpmailer.module \phpmailer_form_mimemail_admin_settings_alter()
  3. 7.4 phpmailer.module \phpmailer_form_mimemail_admin_settings_alter()
  4. 7.3 phpmailer.module \phpmailer_form_mimemail_admin_settings_alter()

Implementation of hook_form_FORM_ID_alter().

This is for the mimemail_admin_settings form.

@todo This whole function needs to be figured out.

File

./phpmailer.module, line 18
Integrates the PHPMailer library for SMTP e-mail delivery.

Code

function phpmailer_form_mimemail_admin_settings_alter(&$form, &$form_state) {

  // Hide the Mime Mail global enabler setting if phpmailer is used to deliver
  // e-mails (they can't be both active).
  if (phpmailer_active()) {
    $mimemail_alter =& $form['mimemail']['mimemail_alter'];
    $mimemail_alter['#disabled'] = TRUE;
    $mimemail_alter['#default_value'] = 0;
    $phpmailer_settings = \Drupal::l(t('PHPMailer settings page'), Url::fromRoute('phpmailer.settings'));
    $mimemail_alter['#description'] = t('PHPMailer has been set to deliver all site messages. To let Mime Mail apply styles and formatting to system e-mails but still use PHPMailer for mail transport, uncheck <em>Use PHPMailer to send e-mails</em> first on the @url. Then activate this setting and choose PHPMailer from the list of e-mail engines below.', [
      '@url' => $phpmailer_settings,
    ]);
  }

  // @todo Move to MimeMail project.

  /**
   * @todo This needs to be figured out.
   */
  $phpmailer_preview = \Drupal::l(t('preview of a styled e-mail'), Url::fromRoute('phpmailer/preview'));
  $form['preview'] = [
    '#type' => 'item',
    '#title' => t('Preview'),
    '#value' => t('See a @url using the current message template (<code>mimemail-message.tpl.php</code>).', [
      '@url' => $phpmailer_preview,
    ]),
  ];
  $form['buttons']['#weight'] = 10;
}