public function TestMailCollector::mail in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Mail/Plugin/Mail/TestMailCollector.php \Drupal\Core\Mail\Plugin\Mail\TestMailCollector::mail()
- 10 core/lib/Drupal/Core/Mail/Plugin/Mail/TestMailCollector.php \Drupal\Core\Mail\Plugin\Mail\TestMailCollector::mail()
Sends an email message.
Parameters
array $message: A message array, as described in hook_mail_alter().
Return value
bool TRUE if the mail was successfully accepted, otherwise FALSE.
Overrides PhpMail::mail
See also
http://php.net/manual/function.mail.php
\Drupal\Core\Mail\MailManagerInterface::mail()
File
- core/
lib/ Drupal/ Core/ Mail/ Plugin/ Mail/ TestMailCollector.php, line 23
Class
- TestMailCollector
- Defines a mail backend that captures sent messages in the state system.
Namespace
Drupal\Core\Mail\Plugin\MailCode
public function mail(array $message) {
$captured_emails = \Drupal::state()
->get('system.test_mail_collector', []);
$captured_emails[] = $message;
\Drupal::state()
->set('system.test_mail_collector', $captured_emails);
return TRUE;
}