SendgridSmtpTransport example

new Dsn('sendgrid+api', 'default', self::USER),
            new SendgridApiTransport(self::USER, new MockHttpClient(), null, $logger),
        ];

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

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

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

        yield [
            new Dsn('sendgrid+smtps', 'default', self::USER),
            new SendgridSmtpTransport(self::USER, null, $logger),
        ];
    }
$scheme = $dsn->getScheme();
        $key = $this->getUser($dsn);

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

            return (new SendgridApiTransport($key$this->client, $this->dispatcher, $this->logger))->setHost($host)->setPort($port);
        }

        if ('sendgrid+smtp' === $scheme || 'sendgrid+smtps' === $scheme || 'sendgrid' === $scheme) {
            return new SendgridSmtpTransport($key$this->dispatcher, $this->logger);
        }

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

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