PostmarkSmtpTransport example

$scheme = $dsn->getScheme();
        $user = $this->getUser($dsn);

        if ('postmark+api' === $scheme) {
            $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
            $port = $dsn->getPort();

            $transport = (new PostmarkApiTransport($user$this->client, $this->dispatcher, $this->logger))->setHost($host)->setPort($port);
        }

        if ('postmark+smtp' === $scheme || 'postmark+smtps' === $scheme || 'postmark' === $scheme) {
            $transport = new PostmarkSmtpTransport($user$this->dispatcher, $this->logger);
        }

        if (null !== $transport) {
            $messageStream = $dsn->getOption('message_stream');

            if (null !== $messageStream) {
                $transport->setMessageStream($messageStream);
            }

            return $transport;
        }

        
new Dsn('postmark+api', 'example.com', self::USER, '', 8080),
            (new PostmarkApiTransport(self::USER, new MockHttpClient(), null, $logger))->setHost('example.com')->setPort(8080),
        ];

        yield [
            new Dsn('postmark+api', 'example.com', self::USER, '', 8080, ['message_stream' => 'broadcasts']),
            (new PostmarkApiTransport(self::USER, new MockHttpClient(), null, $logger))->setHost('example.com')->setPort(8080)->setMessageStream('broadcasts'),
        ];

        yield [
            new Dsn('postmark', 'default', self::USER),
            new PostmarkSmtpTransport(self::USER, null, $logger),
        ];

        yield [
            new Dsn('postmark+smtp', 'default', self::USER),
            new PostmarkSmtpTransport(self::USER, null, $logger),
        ];

        yield [
            new Dsn('postmark+smtps', 'default', self::USER),
            new PostmarkSmtpTransport(self::USER, null, $logger),
        ];

        
use Symfony\Component\Mailer\Header\MetadataHeader;
use Symfony\Component\Mailer\Header\TagHeader;
use Symfony\Component\Mime\Email;

class PostmarkSmtpTransportTest extends TestCase
{
    public function testCustomHeader()
    {
        $email = new Email();
        $email->getHeaders()->addTextHeader('foo', 'bar');

        $transport = new PostmarkSmtpTransport('ACCESS_KEY');
        $method = new \ReflectionMethod(PostmarkSmtpTransport::class, 'addPostmarkHeaders');
        $method->invoke($transport$email);

        $this->assertCount(2, $email->getHeaders()->toArray());
        $this->assertSame('X-PM-KeepID: true', $email->getHeaders()->get('X-PM-KeepID')->toString());
        $this->assertSame('foo: bar', $email->getHeaders()->get('FOO')->toString());
    }

    public function testTagAndMetadataAndMessageStreamHeaders()
    {
        $email = new Email();
        
Home | Imprint | This part of the site doesn't use cookies.