OhMySmtpApiTransport example


    public function create(Dsn $dsn): TransportInterface
    {
        trigger_deprecation('symfony/oh-my-smtp-mailer', '6.2', 'The "%s" class is deprecated, use "%s" instead.', self::class, MailPaceTransportFactory::class);

        $scheme = $dsn->getScheme();

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

            return (new OhMySmtpApiTransport($this->getUser($dsn)$this->client, $this->dispatcher, $this->logger))->setHost($host)->setPort($port);
        }

        if ('ohmysmtp+smtp' === $scheme || 'ohmysmtp+smtps' === $scheme || 'ohmysmtp' === $scheme) {
            return new OhMySmtpSmtpTransport($this->getUser($dsn)$this->dispatcher, $this->logger);
        }

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

    protected function getSupportedSchemes(): array
    {
        
new Dsn('ohmysmtp+smtp', 'example.com'),
            true,
        ];
    }

    public static function createProvider(): iterable
    {
        $logger = new NullLogger();

        yield [
            new Dsn('ohmysmtp+api', 'default', self::USER),
            new OhMySmtpApiTransport(self::USER, new MockHttpClient(), null, $logger),
        ];

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

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

        

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

    public static function getTransportData(): array
    {
        return [
            [
                new OhMySmtpApiTransport('KEY'),
                'ohmysmtp+api://app.ohmysmtp.com/api/v1',
            ],
            [
                (new OhMySmtpApiTransport('KEY'))->setHost('example.com'),
                'ohmysmtp+api://example.com',
            ],
            [
                (new OhMySmtpApiTransport('KEY'))->setHost('example.com')->setPort(99),
                'ohmysmtp+api://example.com:99',
            ],
        ];
    }
Home | Imprint | This part of the site doesn't use cookies.