class HTMLTestingMailSystem in Simplenews 8
Same name and namespace in other branches
- 8.2 src/Plugin/Mail/HTMLTestingMailSystem.php \Drupal\simplenews\Plugin\Mail\HTMLTestingMailSystem
- 3.x src/Plugin/Mail/HTMLTestingMailSystem.php \Drupal\simplenews\Plugin\Mail\HTMLTestingMailSystem
A mail sending implementation that captures sent messages to a variable.
This class is for running tests or for development and does not convert HTML to plaintext.
Plugin annotation
@Mail(
id = "test_simplenews_html_mail",
label = @Translation("HTML test mailer"),
description = @Translation("Sends the message as plain text, using PHP's native mail() function.")
)
Hierarchy
- class \Drupal\simplenews\Plugin\Mail\HTMLTestingMailSystem implements MailInterface
Expanded class hierarchy of HTMLTestingMailSystem
File
- src/
Plugin/ Mail/ HTMLTestingMailSystem.php, line 20
Namespace
Drupal\simplenews\Plugin\MailView source
class HTMLTestingMailSystem implements MailInterface {
/**
* Implements MailSystemInterface::format().
*/
public function format(array $message) {
// Join the body array into one string.
$message['body'] = implode("\n\n", $message['body']);
// Wrap the mail body for sending.
$message['body'] = MailFormatHelper::wrapMail($message['body']);
return $message;
}
/**
* Implements MailSystemInterface::mail().
*/
public function mail(array $message) {
$captured_emails = \Drupal::state()
->get('system.test_mail_collector') ?: array();
$captured_emails[] = $message;
\Drupal::state()
->set('system.test_mail_collector', $captured_emails);
return TRUE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
HTMLTestingMailSystem:: |
public | function |
Implements MailSystemInterface::format(). Overrides MailInterface:: |
|
HTMLTestingMailSystem:: |
public | function |
Implements MailSystemInterface::mail(). Overrides MailInterface:: |