You are here

public function HTMLTestingMailSystem::mail in Simplenews 3.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/Mail/HTMLTestingMailSystem.php \Drupal\simplenews\Plugin\Mail\HTMLTestingMailSystem::mail()
  2. 8 src/Plugin/Mail/HTMLTestingMailSystem.php \Drupal\simplenews\Plugin\Mail\HTMLTestingMailSystem::mail()

Implements MailSystemInterface::mail().

Overrides MailInterface::mail

File

src/Plugin/Mail/HTMLTestingMailSystem.php, line 36

Class

HTMLTestingMailSystem
A mail sending implementation that captures sent messages to a variable.

Namespace

Drupal\simplenews\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;
}