TestPhpMailFailure.php
Same filename in other branches
- 8.9.x core/modules/system/tests/modules/system_mail_failure_test/src/Plugin/Mail/TestPhpMailFailure.php
- 10 core/modules/system/tests/modules/system_mail_failure_test/src/Plugin/Mail/TestPhpMailFailure.php
- 11.x core/modules/system/tests/modules/system_mail_failure_test/src/Plugin/Mail/TestPhpMailFailure.php
Namespace
Drupal\system_mail_failure_test\Plugin\MailFile
-
core/
modules/ system/ tests/ modules/ system_mail_failure_test/ src/ Plugin/ Mail/ TestPhpMailFailure.php
View source
<?php
namespace Drupal\system_mail_failure_test\Plugin\Mail;
use Drupal\Core\Mail\Plugin\Mail\PhpMail;
use Drupal\Core\Mail\MailInterface;
/**
* Defines a mail sending implementation that always fails.
*
* This class is for running tests or for development. To use set the
* configuration:
* @code
* \Drupal::configFactory()->getEditable('system.mail')->set('interface.default', 'test_php_mail_failure')->save();
* @endcode
*
* @Mail(
* id = "test_php_mail_failure",
* label = @Translation("Malfunctioning mail backend"),
* description = @Translation("An intentionally broken mail backend, used for tests.")
* )
*/
class TestPhpMailFailure extends PhpMail implements MailInterface {
/**
* {@inheritdoc}
*/
public function mail(array $message) {
// Simulate a failed mail send by returning FALSE.
return FALSE;
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
TestPhpMailFailure | Defines a mail sending implementation that always fails. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.