You are here

class TestPhpMailFailure in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/system_mail_failure_test/src/Plugin/Mail/TestPhpMailFailure.php \Drupal\system_mail_failure_test\Plugin\Mail\TestPhpMailFailure

Defines a mail sending implementation that always fails.

This class is for running tests or for development. To use set the configuration:

\Drupal::configFactory()
  ->getEditable('system.mail')
  ->set('interface.default', 'test_php_mail_failure')
  ->save();

Plugin annotation


@Mail(
  id = "test_php_mail_failure",
  label = @Translation("Malfunctioning mail backend"),
  description = @Translation("An intentionally broken mail backend, used for tests.")
)

Hierarchy

Expanded class hierarchy of TestPhpMailFailure

1 file declares its use of TestPhpMailFailure
MailTest.php in core/modules/system/tests/src/Kernel/Mail/MailTest.php

File

core/modules/system/tests/modules/system_mail_failure_test/src/Plugin/Mail/TestPhpMailFailure.php, line 23

Namespace

Drupal\system_mail_failure_test\Plugin\Mail
View source
class TestPhpMailFailure extends PhpMail implements MailInterface {

  /**
   * {@inheritdoc}
   */
  public function mail(array $message) {

    // Simulate a failed mail send by returning FALSE.
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PhpMail::$configFactory protected property The configuration factory.
PhpMail::format public function Concatenates and wraps the email body for plain-text mails. Overrides MailInterface::format 1
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.
TestPhpMailFailure::mail public function Sends an email message. Overrides PhpMail::mail