function OriginatorSubscriberTest::testCustomEnvelopeSubscriber
Ensure that the envelope sender can be customized using an event subscriber.
File
-
core/
modules/ mailer/ tests/ src/ Kernel/ OriginatorSubscriberTest.php, line 347
Class
- OriginatorSubscriberTest
- Tests default originator subscriber.
Namespace
Drupal\Tests\mailer\KernelCode
public function testCustomEnvelopeSubscriber() : void {
$expectedAddress = Address::create('subscriber-envelope-sender@example.com');
$state = $this->container
->get('state');
assert($state instanceof StateInterface);
$state->set('mailer_event_subscriber_test.set_custom_envelope_sender', $expectedAddress);
$email = (new Email())->subject('Court response must near however.')
->text('Name have page personal assume actually study else. Play test model scientist provide. City whatever amount sister.');
$transport = $this->container
->get(TransportInterface::class);
assert($transport instanceof TransportInterface);
$sentMessage = $transport->send($email->to('foobar@example.com'));
assert($sentMessage instanceof SentMessage);
$envelope = $sentMessage->getEnvelope();
$actualAddress = $envelope->getSender();
$this->assertEquals($expectedAddress, $actualAddress);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.