You are here

public function MailDebuggerForm::submitForm in Mail Debugger 8

Submit Form Handler.

Overrides FormInterface::submitForm

File

src/Form/MailDebuggerForm.php, line 104

Class

MailDebuggerForm
Class MailDebuggerForm.

Namespace

Drupal\mail_debugger\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $this->storage
    ->set('to', $form_state
    ->getValue('to'));
  $this->storage
    ->set('subject', $form_state
    ->getValue('subject'));
  $this->storage
    ->set('body', $form_state
    ->getValue('body'));
  $summary = $this->mailManager
    ->mail('mail_debugger', 'mail_debugger', $form_state
    ->getValue('to'), NULL, [
    'subject' => $form_state
      ->getValue('subject'),
    'body' => $form_state
      ->getValue('body'),
  ]);
  if ($summary['result']) {
    $this
      ->messenger()
      ->addStatus($this
      ->t("Sent a message."));
  }
}