class TestPhpMailFailure in Drupal 9
Same name and namespace in other branches
- 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
- class \Drupal\Core\Mail\Plugin\Mail\PhpMail implements MailInterface
- class \Drupal\system_mail_failure_test\Plugin\Mail\TestPhpMailFailure implements MailInterface
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\MailView source
class TestPhpMailFailure extends PhpMail implements MailInterface {
/**
* {@inheritdoc}
*/
public function mail(array $message) {
// Simulate a failed mail send by returning FALSE.
return FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PhpMail:: |
protected | property | The configuration factory. | |
PhpMail:: |
public | function |
Concatenates and wraps the email body for plain-text mails. Overrides MailInterface:: |
1 |
PhpMail:: |
private | constant | A list of headers that can contain multiple email addresses. | |
PhpMail:: |
protected static | function | Disallows potentially unsafe shell characters. | |
PhpMail:: |
public | function | PhpMail constructor. | |
TestPhpMailFailure:: |
public | function |
Sends an email message. Overrides PhpMail:: |