class TestMailCollector in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Mail/Plugin/Mail/TestMailCollector.php \Drupal\Core\Mail\Plugin\Mail\TestMailCollector
Defines a mail backend that captures sent messages in the state system.
This class is for running tests or for development.
Plugin annotation
@Mail(
id = "test_mail_collector",
label = @Translation("Mail collector"),
description = @Translation("Does not send the message, but stores it in Drupal within the state system. Used for testing.")
)
Hierarchy
- class \Drupal\Core\Mail\Plugin\Mail\PhpMail implements MailInterface
- class \Drupal\Core\Mail\Plugin\Mail\TestMailCollector implements MailInterface
Expanded class hierarchy of TestMailCollector
1 file declares its use of TestMailCollector
- MailTest.php in core/
modules/ system/ src/ Tests/ Mail/ MailTest.php - Contains \Drupal\system\Tests\Mail\MailTest.
File
- core/
lib/ Drupal/ Core/ Mail/ Plugin/ Mail/ TestMailCollector.php, line 23 - Contains \Drupal\Core\Mail\Plugin\Mail\TestMailCollector.
Namespace
Drupal\Core\Mail\Plugin\MailView source
class TestMailCollector extends PhpMail implements MailInterface {
/**
* {@inheritdoc}
*/
public function mail(array $message) {
$captured_emails = \Drupal::state()
->get('system.test_mail_collector') ?: array();
$captured_emails[] = $message;
\Drupal::state()
->set('system.test_mail_collector', $captured_emails);
return TRUE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PhpMail:: |
public | function |
Concatenates and wraps the email body for plain-text mails. Overrides MailInterface:: |
|
TestMailCollector:: |
public | function |
Sends an email message. Overrides PhpMail:: |