You are here

class TestHtmlMailCollector in Drupal 9

Same name and namespace in other branches
  1. 8 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

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\Mail
View 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

Namesort descending Modifiers Type Description Overrides
PhpMail::$configFactory protected property The configuration factory.
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.
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