MailgunHttpTransport example


    public function testToString(MailgunHttpTransport $transport, string $expected)
    {
        $this->assertSame($expected(string) $transport);
    }

    public static function getTransportData()
    {
        return [
            [
                new MailgunHttpTransport('ACCESS_KEY', 'DOMAIN'),
                'mailgun+https://api.mailgun.net?domain=DOMAIN',
            ],
            [
                new MailgunHttpTransport('ACCESS_KEY', 'DOMAIN', 'us-east-1'),
                'mailgun+https://api.us-east-1.mailgun.net?domain=DOMAIN',
            ],
            [
                (new MailgunHttpTransport('ACCESS_KEY', 'DOMAIN'))->setHost('example.com'),
                'mailgun+https://example.com?domain=DOMAIN',
            ],
            [
                (
new Dsn('mailgun+api', 'default', self::USER, self::PASSWORD, null, ['region' => 'eu']),
            new MailgunApiTransport(self::USER, self::PASSWORD, 'eu', $client, null, $logger),
        ];

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

        yield [
            new Dsn('mailgun', 'default', self::USER, self::PASSWORD),
            new MailgunHttpTransport(self::USER, self::PASSWORD, null, $client, null, $logger),
        ];

        yield [
            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),
        ];

        
$user = $this->getUser($dsn);
        $password = $this->getPassword($dsn);
        $region = $dsn->getOption('region');
        $host = 'default' === $dsn->getHost() ? null : $dsn->getHost();
        $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
    {
        
Home | Imprint | This part of the site doesn't use cookies.