TestHtmlMailCollector.php
Same filename in other branches
Namespace
Drupal\mail_html_test\Plugin\MailFile
-
core/
modules/ system/ tests/ modules/ mail_html_test/ src/ Plugin/ Mail/ TestHtmlMailCollector.php
View source
<?php
declare (strict_types=1);
namespace Drupal\mail_html_test\Plugin\Mail;
use Drupal\Core\Mail\Attribute\Mail;
use Drupal\Core\Mail\MailFormatHelper;
use Drupal\Core\Mail\Plugin\Mail\TestMailCollector;
use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
* 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.
*/
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;
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
TestHtmlMailCollector | Defines a mail backend that captures sent HTML messages in the state system. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.