DummyStream example

$this->assertEquals('smtps://example.com', (string) $t);

        $t = new EsmtpTransport('example.com', 0, false);
        $this->assertEquals('smtp://example.com', (string) $t);

        $t = new EsmtpTransport('example.com', 466, true);
        $this->assertEquals('smtps://example.com:466', (string) $t);
    }

    public function testExtensibility()
    {
        $stream = new DummyStream();
        $transport = new CustomEsmtpTransport(stream: $stream);

        $message = new Email();
        $message->from('[email protected]');
        $message->addTo('[email protected]');
        $message->text('.');

        $transport->send($message);

        $this->assertContains("MAIL FROM:<[email protected]> RET=HDRS\r\n", $stream->getCommands());
        $this->assertContains("RCPT TO:<[email protected]> NOTIFY=FAILURE\r\n", $stream->getCommands());
    }
public function testToString()
    {
        $t = new SmtpTransport();
        $this->assertEquals('smtps://localhost', (string) $t);

        $t = new SmtpTransport((new SocketStream())->setHost('127.0.0.1')->setPort(2525)->disableTls());
        $this->assertEquals('smtp://127.0.0.1:2525', (string) $t);
    }

    public function testSendDoesNotPingBelowThreshold()
    {
        $stream = new DummyStream();
        $envelope = new Envelope(new Address('[email protected]')[new Address('[email protected]')]);

        $transport = new SmtpTransport($stream);
        $transport->send(new RawMessage('Message 1')$envelope);
        $transport->send(new RawMessage('Message 2')$envelope);
        $transport->send(new RawMessage('Message 3')$envelope);

        $this->assertNotContains("NOOP\r\n", $stream->getCommands());
    }

    public function testSendPingAfterTransportException()
    {
Home | Imprint | This part of the site doesn't use cookies.