class TestMailCollector
Same name in other branches
- 9 core/lib/Drupal/Core/Mail/Plugin/Mail/TestMailCollector.php \Drupal\Core\Mail\Plugin\Mail\TestMailCollector
- 8.9.x core/lib/Drupal/Core/Mail/Plugin/Mail/TestMailCollector.php \Drupal\Core\Mail\Plugin\Mail\TestMailCollector
- 10 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.
Hierarchy
- class \Drupal\Core\Mail\Plugin\Mail\PhpMail implements \Drupal\Core\Mail\MailInterface
- class \Drupal\Core\Mail\Plugin\Mail\TestMailCollector extends \Drupal\Core\Mail\Plugin\Mail\PhpMail implements \Drupal\Core\Mail\MailInterface
Expanded class hierarchy of TestMailCollector
2 files declare their use of TestMailCollector
- MailTest.php in core/
modules/ system/ tests/ src/ Kernel/ Mail/ MailTest.php - TestHtmlMailCollector.php in core/
modules/ system/ tests/ modules/ mail_html_test/ src/ Plugin/ Mail/ TestHtmlMailCollector.php
File
-
core/
lib/ Drupal/ Core/ Mail/ Plugin/ Mail/ TestMailCollector.php, line 14
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', []);
$captured_emails[] = $message;
\Drupal::state()->set('system.test_mail_collector', $captured_emails);
return TRUE;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
PhpMail::$configFactory | protected | property | The configuration factory. | ||
PhpMail::$request | protected | property | The currently active request object. | ||
PhpMail::doMail | protected | function | Wrapper around PHP's mail() function. | ||
PhpMail::format | public | function | Concatenates and wraps the email body for plain-text mails. | Overrides MailInterface::format | 1 |
PhpMail::MAILBOX_LIST_HEADERS | private | constant | A list of headers that can contain multiple email addresses. | ||
PhpMail::_isShellSafe | protected static | function | Disallows potentially unsafe shell characters. | ||
PhpMail::__construct | public | function | PhpMail constructor. | ||
TestMailCollector::mail | public | function | Sends an email message. | Overrides PhpMail::mail |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.