Skip to content

Commit a300795

Browse files
committed
[Mailer] added a name to the transport
1 parent 5d5e04b commit a300795

20 files changed

+109
-0
lines changed

src/Symfony/Component/Mailer/Bridge/Amazon/Transport/SesApiTransport.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ public function __construct(string $accessKey, string $secretKey, string $region
4343
parent::__construct($client, $dispatcher, $logger);
4444
}
4545

46+
public function getName(): string
47+
{
48+
return sprintf('api://%s@ses?region=%s', $this->accessKey, $this->region);
49+
}
50+
4651
protected function doSendApi(Email $email, SmtpEnvelope $envelope): ResponseInterface
4752
{
4853
$date = gmdate('D, d M Y H:i:s e');

src/Symfony/Component/Mailer/Bridge/Amazon/Transport/SesHttpTransport.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public function __construct(string $accessKey, string $secretKey, string $region
4242
parent::__construct($client, $dispatcher, $logger);
4343
}
4444

45+
public function getName(): string
46+
{
47+
return sprintf('http://%s@ses?region=%s', $this->accessKey, $this->region);
48+
}
49+
4550
protected function doSendHttp(SentMessage $message): ResponseInterface
4651
{
4752
$date = gmdate('D, d M Y H:i:s e');

src/Symfony/Component/Mailer/Bridge/Mailchimp/Transport/MandrillApiTransport.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ public function __construct(string $key, HttpClientInterface $client = null, Eve
3636
parent::__construct($client, $dispatcher, $logger);
3737
}
3838

39+
public function getName(): string
40+
{
41+
return sprintf('api://mandrill');
42+
}
43+
3944
protected function doSendApi(Email $email, SmtpEnvelope $envelope): ResponseInterface
4045
{
4146
$response = $this->client->request('POST', self::ENDPOINT, [

src/Symfony/Component/Mailer/Bridge/Mailchimp/Transport/MandrillHttpTransport.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ public function __construct(string $key, HttpClientInterface $client = null, Eve
3434
parent::__construct($client, $dispatcher, $logger);
3535
}
3636

37+
public function getName(): string
38+
{
39+
return sprintf('http://mandrill');
40+
}
41+
3742
protected function doSendHttp(SentMessage $message): ResponseInterface
3843
{
3944
$envelope = $message->getEnvelope();

src/Symfony/Component/Mailer/Bridge/Mailgun/Transport/MailgunApiTransport.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public function __construct(string $key, string $domain, string $region = null,
4141
parent::__construct($client, $dispatcher, $logger);
4242
}
4343

44+
public function getName(): string
45+
{
46+
return sprintf('api://%s@mailgun?region=%s', $this->domain, $this->region);
47+
}
48+
4449
protected function doSendApi(Email $email, SmtpEnvelope $envelope): ResponseInterface
4550
{
4651
$body = new FormDataPart($this->getPayload($email, $envelope));

src/Symfony/Component/Mailer/Bridge/Mailgun/Transport/MailgunHttpTransport.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ public function __construct(string $key, string $domain, string $region = null,
4040
parent::__construct($client, $dispatcher, $logger);
4141
}
4242

43+
public function getName(): string
44+
{
45+
return sprintf('http://%s@mailgun?region=%s', $this->domain, $this->region);
46+
}
47+
4348
protected function doSendHttp(SentMessage $message): ResponseInterface
4449
{
4550
$body = new FormDataPart([

src/Symfony/Component/Mailer/Bridge/Postmark/Transport/PostmarkApiTransport.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ public function __construct(string $key, HttpClientInterface $client = null, Eve
3636
parent::__construct($client, $dispatcher, $logger);
3737
}
3838

39+
public function getName(): string
40+
{
41+
return sprintf('api://postmark');
42+
}
43+
3944
protected function doSendApi(Email $email, SmtpEnvelope $envelope): ResponseInterface
4045
{
4146
$response = $this->client->request('POST', self::ENDPOINT, [

src/Symfony/Component/Mailer/Bridge/Sendgrid/Transport/SendgridApiTransport.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public function __construct(string $key, HttpClientInterface $client = null, Eve
3737
parent::__construct($client, $dispatcher, $logger);
3838
}
3939

40+
public function getName(): string
41+
{
42+
return sprintf('api://sendgrid');
43+
}
44+
4045
protected function doSendApi(Email $email, SmtpEnvelope $envelope): ResponseInterface
4146
{
4247
$response = $this->client->request('POST', self::ENDPOINT, [

src/Symfony/Component/Mailer/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
4.4.0
55
-----
66

7+
* [BC BREAK] `TransportInterface` has a new `getName()` method
78
* [BC BREAK] Classes `AbstractApiTransport` and `AbstractHttpTransport` moved under `Transport` sub-namespace.
89
* [BC BREAK] Transports depend on `Symfony\Contracts\EventDispatcher\EventDispatcherInterface`
910
instead of `Symfony\Component\EventDispatcher\EventDispatcherInterface`.

src/Symfony/Component/Mailer/Test/TransportFactoryTestCase.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ public function testCreate(Dsn $dsn, TransportInterface $transport): void
6969
$factory = $this->getFactory();
7070

7171
$this->assertEquals($transport, $factory->create($dsn));
72+
if ('smtp' !== $dsn->getScheme()) {
73+
$this->assertStringMatchesFormat($dsn->getScheme().'://%S'.$dsn->getHost().'%S', $transport->getName());
74+
}
7275
}
7376

7477
/**

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy