MailgunSmtpTransport example

$port = $dsn->getPort();

        if ('mailgun+api' === $scheme) {
            return (new MailgunApiTransport($user$password$region$this->client, $this->dispatcher, $this->logger))->setHost($host)->setPort($port);
        }

        if ('mailgun+https' === $scheme || 'mailgun' === $scheme) {
            return (new MailgunHttpTransport($user$password$region$this->client, $this->dispatcher, $this->logger))->setHost($host)->setPort($port);
        }

        if ('mailgun+smtp' === $scheme || 'mailgun+smtps' === $scheme) {
            return new MailgunSmtpTransport($user$password$region$this->dispatcher, $this->logger);
        }

        throw new UnsupportedSchemeException($dsn, 'mailgun', $this->getSupportedSchemes());
    }

    protected function getSupportedSchemes(): array
    {
        return ['mailgun', 'mailgun+api', 'mailgun+https', 'mailgun+smtp', 'mailgun+smtps'];
    }
}

class MailgunSmtpTransportTest extends TestCase
{
    public function testTagAndMetadataHeaders()
    {
        $email = new Email();
        $email->getHeaders()->addTextHeader('foo', 'bar');
        $email->getHeaders()->add(new TagHeader('password-reset'));
        $email->getHeaders()->add(new MetadataHeader('Color', 'blue'));
        $email->getHeaders()->add(new MetadataHeader('Client-ID', '12345'));

        $transport = new MailgunSmtpTransport('user', 'password');
        $method = new \ReflectionMethod(MailgunSmtpTransport::class, 'addMailgunHeaders');
        $method->invoke($transport$email);

        $this->assertCount(3, $email->getHeaders()->toArray());
        $this->assertSame('foo: bar', $email->getHeaders()->get('foo')->toString());
        $this->assertSame('X-Mailgun-Tag: password-reset', $email->getHeaders()->get('X-Mailgun-Tag')->toString());
        $this->assertSame('X-Mailgun-Variables: '.json_encode(['Color' => 'blue', 'Client-ID' => '12345'])$email->getHeaders()->get('X-Mailgun-Variables')->toString());
    }
}
new Dsn('mailgun+https', 'default', self::USER, self::PASSWORD),
            new MailgunHttpTransport(self::USER, self::PASSWORD, null, $client, null, $logger),
        ];

        yield [
            new Dsn('mailgun+https', 'example.com', self::USER, self::PASSWORD, 8080),
            (new MailgunHttpTransport(self::USER, self::PASSWORD, null, $client, null, $logger))->setHost('example.com')->setPort(8080),
        ];

        yield [
            new Dsn('mailgun+smtp', 'default', self::USER, self::PASSWORD),
            new MailgunSmtpTransport(self::USER, self::PASSWORD, null, null, $logger),
        ];

        yield [
            new Dsn('mailgun+smtps', 'default', self::USER, self::PASSWORD),
            new MailgunSmtpTransport(self::USER, self::PASSWORD, null, null, $logger),
        ];
    }

    public static function unsupportedSchemeProvider(): iterable
    {
        yield [
            
Home | Imprint | This part of the site doesn't use cookies.