MandrillSmtpTransport example

class MandrillSmtpTransportTest extends TestCase
{
    public function testTagAndMetadataHeaders()
    {
        $email = new Email();
        $email->getHeaders()->addTextHeader('foo', 'bar');
        $email->getHeaders()->add(new TagHeader('password-reset,user'));
        $email->getHeaders()->add(new TagHeader('another'));
        $email->getHeaders()->add(new MetadataHeader('Color', 'blue'));
        $email->getHeaders()->add(new MetadataHeader('Client-ID', '12345'));

        $transport = new MandrillSmtpTransport('user', 'password');
        $method = new \ReflectionMethod(MandrillSmtpTransport::class, 'addMandrillHeaders');
        $method->invoke($transport$email);

        $this->assertCount(3, $email->getHeaders()->toArray());
        $this->assertSame('foo: bar', $email->getHeaders()->get('FOO')->toString());
        $this->assertSame('X-MC-Tags: password-reset,user,another', $email->getHeaders()->get('X-MC-Tags')->toString());
        $this->assertSame('X-MC-Metadata: '.json_encode(['Color' => 'blue', 'Client-ID' => '12345'])$email->getHeaders()->get('X-MC-Metadata')->toString());
    }
}
new Dsn('mandrill+https', 'default', self::USER),
            new MandrillHttpTransport(self::USER, $client, null, $logger),
        ];

        yield [
            new Dsn('mandrill+https', 'example.com', self::USER, '', 8080),
            (new MandrillHttpTransport(self::USER, $client, null, $logger))->setHost('example.com')->setPort(8080),
        ];

        yield [
            new Dsn('mandrill+smtp', 'default', self::USER, self::PASSWORD),
            new MandrillSmtpTransport(self::USER, self::PASSWORD, null, $logger),
        ];

        yield [
            new Dsn('mandrill+smtps', 'default', self::USER, self::PASSWORD),
            new MandrillSmtpTransport(self::USER, self::PASSWORD, null, $logger),
        ];
    }

    public static function unsupportedSchemeProvider(): iterable
    {
        yield [
            
if ('mandrill+api' === $scheme) {
            return (new MandrillApiTransport($user$this->client, $this->dispatcher, $this->logger))->setHost($host)->setPort($port);
        }

        if ('mandrill+https' === $scheme || 'mandrill' === $scheme) {
            return (new MandrillHttpTransport($user$this->client, $this->dispatcher, $this->logger))->setHost($host)->setPort($port);
        }

        if ('mandrill+smtp' === $scheme || 'mandrill+smtps' === $scheme) {
            $password = $this->getPassword($dsn);

            return new MandrillSmtpTransport($user$password$this->dispatcher, $this->logger);
        }

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

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