public function TestEmailForm::submitForm in Reroute Email 2.x
Same name and namespace in other branches
- 8 src/Form/TestEmailForm.php \Drupal\reroute_email\Form\TestEmailForm::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/ TestEmailForm.php, line 114
Class
- TestEmailForm
- Implements a form to test Reroute Email.
Namespace
Drupal\reroute_email\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$to = $form_state
->getValue([
'to',
]);
$param_keys = [
'cc',
'bcc',
'subject',
'body',
];
$params = array_intersect_key($form_state
->getValues(), array_flip($param_keys));
$langcode = $this->languageManager
->getDefaultLanguage()
->getId();
// Send email with drupal_mail.
$message = $this->mailManager
->mail('reroute_email', 'test_email_form', $to, $langcode, $params);
if (!empty($message['result'])) {
$this->messenger
->addMessage($this
->t('Test email submitted for delivery from test form.'));
}
}