SendinblueApiTransport example

new Dsn('sendinblue+smtp', 'default', self::USER, self::PASSWORD),
            new SendinblueSmtpTransport(self::USER, self::PASSWORD, null, new NullLogger()),
        ];

        yield [
            new Dsn('sendinblue+smtp', 'default', self::USER, self::PASSWORD, 465),
            new SendinblueSmtpTransport(self::USER, self::PASSWORD, null, new NullLogger()),
        ];

        yield [
            new Dsn('sendinblue+api', 'default', self::USER),
            new SendinblueApiTransport(self::USER, new MockHttpClient(), null, new NullLogger()),
        ];
    }

    public static function unsupportedSchemeProvider(): iterable
    {
        yield [
            new Dsn('sendinblue+foo', 'default', self::USER, self::PASSWORD),
            'The "sendinblue+foo" scheme is not supported; supported schemes for mailer "sendinblue" are: "sendinblue", "sendinblue+smtp", "sendinblue+api".',
        ];
    }

    
/** * @dataProvider getTransportData */
    public function testToString(SendinblueApiTransport $transport, string $expected)
    {
        $this->assertSame($expected(string) $transport);
    }

    public static function getTransportData()
    {
        yield [
            new SendinblueApiTransport('ACCESS_KEY'),
            'sendinblue+api://api.sendinblue.com',
        ];

        yield [
            (new SendinblueApiTransport('ACCESS_KEY'))->setHost('example.com'),
            'sendinblue+api://example.com',
        ];

        yield [
            (new SendinblueApiTransport('ACCESS_KEY'))->setHost('example.com')->setPort(99),
            'sendinblue+api://example.com:99',
        ];
if (!\in_array($dsn->getScheme()$this->getSupportedSchemes(), true)) {
            throw new UnsupportedSchemeException($dsn, 'sendinblue', $this->getSupportedSchemes());
        }

        switch ($dsn->getScheme()) {
            default:
            case 'sendinblue':
            case 'sendinblue+smtp':
                $transport = SendinblueSmtpTransport::class;
                break;
            case 'sendinblue+api':
                return (new SendinblueApiTransport($this->getUser($dsn)$this->client, $this->dispatcher, $this->logger))
                    ->setHost('default' === $dsn->getHost() ? null : $dsn->getHost())
                    ->setPort($dsn->getPort())
                ;
        }

        return new $transport($this->getUser($dsn)$this->getPassword($dsn)$this->dispatcher, $this->logger);
    }

    protected function getSupportedSchemes(): array
    {
        return ['sendinblue', 'sendinblue+smtp', 'sendinblue+api'];
    }
Home | Imprint | This part of the site doesn't use cookies.