You are here

public function TestMailCollector::mail in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Mail/Plugin/Mail/TestMailCollector.php \Drupal\Core\Mail\Plugin\Mail\TestMailCollector::mail()
  2. 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\Mail

Code

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;
}