class TestHtmlMailCollector
Same name in other branches
- 9 core/modules/system/tests/modules/mail_html_test/src/Plugin/Mail/TestHtmlMailCollector.php \Drupal\mail_html_test\Plugin\Mail\TestHtmlMailCollector
- 10 core/modules/system/tests/modules/mail_html_test/src/Plugin/Mail/TestHtmlMailCollector.php \Drupal\mail_html_test\Plugin\Mail\TestHtmlMailCollector
- 11.x core/modules/system/tests/modules/mail_html_test/src/Plugin/Mail/TestHtmlMailCollector.php \Drupal\mail_html_test\Plugin\Mail\TestHtmlMailCollector
Defines a mail backend that captures sent HTML messages in the state system.
This class is for running tests or for development and does not convert HTML to plaintext.
Plugin annotation
@Mail(
id = "test_html_mail_collector",
label = @Translation("HTML mail collector"),
description = @Translation("Does not send the message, but stores its HTML in Drupal within the state system. Used for testing.")
)
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
- class \Drupal\mail_html_test\Plugin\Mail\TestHtmlMailCollector extends \Drupal\Core\Mail\Plugin\Mail\TestMailCollector
- class \Drupal\Core\Mail\Plugin\Mail\TestMailCollector extends \Drupal\Core\Mail\Plugin\Mail\PhpMail implements \Drupal\Core\Mail\MailInterface
Expanded class hierarchy of TestHtmlMailCollector
File
-
core/
modules/ system/ tests/ modules/ mail_html_test/ src/ Plugin/ Mail/ TestHtmlMailCollector.php, line 20
Namespace
Drupal\mail_html_test\Plugin\MailView source
class TestHtmlMailCollector extends TestMailCollector {
/**
* {@inheritdoc}
*/
public function format(array $message) {
// Join the body array into one string.
$message['body'] = implode(PHP_EOL, $message['body']);
// Wrap the mail body for sending.
$message['body'] = MailFormatHelper::wrapMail($message['body']);
return $message;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
PhpMail::$configFactory | protected | property | The configuration factory. | |
PhpMail::_isShellSafe | protected static | function | Disallows potentially unsafe shell characters. | |
PhpMail::__construct | public | function | PhpMail constructor. | |
TestHtmlMailCollector::format | public | function | Concatenates and wraps the email body for plain-text mails. | Overrides PhpMail::format |
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.