MailPaceSmtpTransport example


        $scheme = $dsn->getScheme();

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

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

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

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

    protected function getSupportedSchemes(): array
    {
        return ['mailpace', 'mailpace+api', 'mailpace+smtp', 'mailpace+smtps'];
    }
}
use Symfony\Component\Mailer\Bridge\MailPace\Transport\MailPaceSmtpTransport;
use Symfony\Component\Mailer\Header\TagHeader;
use Symfony\Component\Mime\Email;

final class MailPaceSmtpTransportTest extends TestCase
{
    public function testCustomHeader()
    {
        $email = new Email();
        $email->getHeaders()->addTextHeader('foo', 'bar');

        $transport = new MailPaceSmtpTransport('ACCESS_KEY');
        $method = new \ReflectionMethod(MailPaceSmtpTransport::class, 'addMailPaceHeaders');
        $method->invoke($transport$email);

        $this->assertCount(1, $email->getHeaders()->toArray());
        $this->assertSame('foo: bar', $email->getHeaders()->get('FOO')->toString());
    }

    public function testTagAndMetadataHeaders()
    {
        $email = new Email();
        $email->getHeaders()->addTextHeader('foo', 'bar');
        
new Dsn('mailpace+api', 'default', self::USER),
            new MailPaceApiTransport(self::USER, new MockHttpClient(), null, $logger),
        ];

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

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

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

        yield [
            new Dsn('mailpace+smtps', 'default', self::USER),
            new MailPaceSmtpTransport(self::USER, null, $logger),
        ];
    }
Home | Imprint | This part of the site doesn't use cookies.