MailerSendSmtpTransport example

yield [
            new Dsn('mailersend+api', 'default'),
            true,
        ];
    }

    public static function createProvider(): iterable
    {
        yield [
            new Dsn('mailersend', 'default', self::USER, self::PASSWORD),
            new MailerSendSmtpTransport(self::USER, self::PASSWORD, null, new NullLogger()),
        ];

        yield [
            new Dsn('mailersend+smtp', 'default', self::USER, self::PASSWORD),
            new MailerSendSmtpTransport(self::USER, self::PASSWORD, null, new NullLogger()),
        ];

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

        

final class MailerSendTransportFactory extends AbstractTransportFactory
{
    public function create(Dsn $dsn): TransportInterface
    {
        return match ($dsn->getScheme()) {
            'mailersend+api' => (new MailerSendApiTransport($this->getUser($dsn)$this->client, $this->dispatcher, $this->logger))
                ->setHost('default' === $dsn->getHost() ? null : $dsn->getHost())
                ->setPort($dsn->getPort()),

            'mailersend', 'mailersend+smtp' => new MailerSendSmtpTransport($this->getUser($dsn)$this->getPassword($dsn)$this->dispatcher, $this->logger),

            default => throw new UnsupportedSchemeException($dsn, 'mailersend', $this->getSupportedSchemes())
        };
    }

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