You are here

public function TestForm::submitForm in Swift Mailer 8

Same name and namespace in other branches
  1. 8.2 src/Form/TestForm.php \Drupal\swiftmailer\Form\TestForm::submitForm()

Form submission handler.

Parameters

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

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

src/Form/TestForm.php, line 56

Class

TestForm
Swift Mailer test form.

Namespace

Drupal\swiftmailer\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  \Drupal::service('plugin.manager.mail')
    ->mail('swiftmailer', 'test', $form_state
    ->getValue([
    'test',
    'recipient',
  ]), \Drupal::languageManager()
    ->getDefaultLanguage()
    ->getId());
  \Drupal::messenger()
    ->addMessage($this
    ->t('An attempt has been made to send an e-mail to @email.', [
    '@email' => $form_state
      ->getValue([
      'test',
      'recipient',
    ]),
  ]));
}