class TestPhpMailFailure

Same name and namespace in other branches
  1. 11.x 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;
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.