TestPhpMailFailure.php

Same filename in other branches
  1. 9 core/modules/system/tests/modules/system_mail_failure_test/src/Plugin/Mail/TestPhpMailFailure.php
  2. 8.9.x core/modules/system/tests/modules/system_mail_failure_test/src/Plugin/Mail/TestPhpMailFailure.php
  3. 11.x core/modules/system/tests/modules/system_mail_failure_test/src/Plugin/Mail/TestPhpMailFailure.php

Namespace

Drupal\system_mail_failure_test\Plugin\Mail

File

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\Attribute\Mail;
use Drupal\Core\Mail\Plugin\Mail\PhpMail;
use Drupal\Core\Mail\MailInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
 * 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
 */
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.