class TestHtmlMailCollector in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/tests/modules/mail_html_test/src/Plugin/Mail/TestHtmlMailCollector.php \Drupal\mail_html_test\Plugin\Mail\TestHtmlMailCollector
- 9 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 MailInterface
- class \Drupal\Core\Mail\Plugin\Mail\TestMailCollector implements MailInterface
- class \Drupal\mail_html_test\Plugin\Mail\TestHtmlMailCollector
- class \Drupal\Core\Mail\Plugin\Mail\TestMailCollector implements 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PhpMail:: |
protected | property | The configuration factory. | |
PhpMail:: |
private | constant | A list of headers that can contain multiple email addresses. | |
PhpMail:: |
protected static | function | Disallows potentially unsafe shell characters. | |
PhpMail:: |
public | function | PhpMail constructor. | |
TestHtmlMailCollector:: |
public | function |
Concatenates and wraps the email body for plain-text mails. Overrides PhpMail:: |
|
TestMailCollector:: |
public | function |
Sends an email message. Overrides PhpMail:: |