Skip to content

Commit 1042a3c

Browse files
committed
[Mailer] simplified the way TLS/SSL/StartTls work
1 parent bc79cfe commit 1042a3c

28 files changed

+189
-63
lines changed

src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesTransportFactoryTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ public function supportsProvider(): iterable
4343
true,
4444
];
4545

46+
yield [
47+
new Dsn('smtps', 'ses'),
48+
true,
49+
];
50+
4651
yield [
4752
new Dsn('smtp', 'example.com'),
4853
false,
@@ -84,13 +89,18 @@ public function createProvider(): iterable
8489
new Dsn('smtp', 'ses', self::USER, self::PASSWORD, null, ['region' => 'eu-west-1']),
8590
new SesSmtpTransport(self::USER, self::PASSWORD, 'eu-west-1', $dispatcher, $logger),
8691
];
92+
93+
yield [
94+
new Dsn('smtps', 'ses', self::USER, self::PASSWORD, null, ['region' => 'eu-west-1']),
95+
new SesSmtpTransport(self::USER, self::PASSWORD, 'eu-west-1', $dispatcher, $logger),
96+
];
8797
}
8898

8999
public function unsupportedSchemeProvider(): iterable
90100
{
91101
yield [
92102
new Dsn('foo', 'ses', self::USER, self::PASSWORD),
93-
'The "foo" scheme is not supported for mailer "ses". Supported schemes are: "api", "http", "smtp".',
103+
'The "foo" scheme is not supported for mailer "ses". Supported schemes are: "api", "http", "smtp", "smtps".',
94104
];
95105
}
96106

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class SesSmtpTransport extends EsmtpTransport
2525
*/
2626
public function __construct(string $username, string $password, string $region = null, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
2727
{
28-
parent::__construct(sprintf('email-smtp.%s.amazonaws.com', $region ?: 'eu-west-1'), 587, 'tls', null, $dispatcher, $logger);
28+
parent::__construct(sprintf('email-smtp.%s.amazonaws.com', $region ?: 'eu-west-1'), 587, true, null, $dispatcher, $logger);
2929

3030
$this->setUsername($username);
3131
$this->setPassword($password);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ public function create(Dsn $dsn): TransportInterface
3636
return new SesHttpTransport($user, $password, $region, $this->client, $this->dispatcher, $this->logger);
3737
}
3838

39-
if ('smtp' === $scheme) {
39+
if ('smtp' === $scheme || 'smtps' === $scheme) {
4040
return new SesSmtpTransport($user, $password, $region, $this->dispatcher, $this->logger);
4141
}
4242

43-
throw new UnsupportedSchemeException($dsn, ['api', 'http', 'smtp']);
43+
throw new UnsupportedSchemeException($dsn, ['api', 'http', 'smtp', 'smtps']);
4444
}
4545

4646
public function supports(Dsn $dsn): bool

src/Symfony/Component/Mailer/Bridge/Google/Tests/Transport/GmailTransportFactoryTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ public function supportsProvider(): iterable
2222
true,
2323
];
2424

25+
yield [
26+
new Dsn('smtps', 'gmail'),
27+
true,
28+
];
29+
2530
yield [
2631
new Dsn('smtp', 'example.com'),
2732
false,
@@ -34,13 +39,18 @@ public function createProvider(): iterable
3439
new Dsn('smtp', 'gmail', self::USER, self::PASSWORD),
3540
new GmailSmtpTransport(self::USER, self::PASSWORD, $this->getDispatcher(), $this->getLogger()),
3641
];
42+
43+
yield [
44+
new Dsn('smtps', 'gmail', self::USER, self::PASSWORD),
45+
new GmailSmtpTransport(self::USER, self::PASSWORD, $this->getDispatcher(), $this->getLogger()),
46+
];
3747
}
3848

3949
public function unsupportedSchemeProvider(): iterable
4050
{
4151
yield [
4252
new Dsn('foo', 'gmail', self::USER, self::PASSWORD),
43-
'The "foo" scheme is not supported for mailer "gmail". Supported schemes are: "smtp".',
53+
'The "foo" scheme is not supported for mailer "gmail". Supported schemes are: "smtp", "smtps".',
4454
];
4555
}
4656

src/Symfony/Component/Mailer/Bridge/Google/Transport/GmailSmtpTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class GmailSmtpTransport extends EsmtpTransport
2222
{
2323
public function __construct(string $username, string $password, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
2424
{
25-
parent::__construct('smtp.gmail.com', 465, 'ssl', null, $dispatcher, $logger);
25+
parent::__construct('smtp.gmail.com', 465, true, null, $dispatcher, $logger);
2626

2727
$this->setUsername($username);
2828
$this->setPassword($password);

src/Symfony/Component/Mailer/Bridge/Google/Transport/GmailTransportFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ final class GmailTransportFactory extends AbstractTransportFactory
2323
{
2424
public function create(Dsn $dsn): TransportInterface
2525
{
26-
if ('smtp' === $dsn->getScheme()) {
26+
if ('smtp' === $dsn->getScheme() || 'smtps' === $dsn->getScheme()) {
2727
return new GmailSmtpTransport($this->getUser($dsn), $this->getPassword($dsn), $this->dispatcher, $this->logger);
2828
}
2929

30-
throw new UnsupportedSchemeException($dsn, ['smtp']);
30+
throw new UnsupportedSchemeException($dsn, ['smtp', 'smtps']);
3131
}
3232

3333
public function supports(Dsn $dsn): bool

src/Symfony/Component/Mailer/Bridge/Mailchimp/Tests/Transport/MandrillTransportFactoryTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ public function supportsProvider(): iterable
4343
true,
4444
];
4545

46+
yield [
47+
new Dsn('smtps', 'mandrill'),
48+
true,
49+
];
50+
4651
yield [
4752
new Dsn('smtp', 'example.com'),
4853
false,
@@ -69,13 +74,18 @@ public function createProvider(): iterable
6974
new Dsn('smtp', 'mandrill', self::USER, self::PASSWORD),
7075
new MandrillSmtpTransport(self::USER, self::PASSWORD, $dispatcher, $logger),
7176
];
77+
78+
yield [
79+
new Dsn('smtps', 'mandrill', self::USER, self::PASSWORD),
80+
new MandrillSmtpTransport(self::USER, self::PASSWORD, $dispatcher, $logger),
81+
];
7282
}
7383

7484
public function unsupportedSchemeProvider(): iterable
7585
{
7686
yield [
7787
new Dsn('foo', 'mandrill', self::USER),
78-
'The "foo" scheme is not supported for mailer "mandrill". Supported schemes are: "api", "http", "smtp".',
88+
'The "foo" scheme is not supported for mailer "mandrill". Supported schemes are: "api", "http", "smtp", "smtps".',
7989
];
8090
}
8191

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class MandrillSmtpTransport extends EsmtpTransport
2222
{
2323
public function __construct(string $username, string $password, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
2424
{
25-
parent::__construct('smtp.mandrillapp.com', 587, 'tls', null, $dispatcher, $logger);
25+
parent::__construct('smtp.mandrillapp.com', 587, true, null, $dispatcher, $logger);
2626

2727
$this->setUsername($username);
2828
$this->setPassword($password);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ public function create(Dsn $dsn): TransportInterface
3434
return new MandrillHttpTransport($user, $this->client, $this->dispatcher, $this->logger);
3535
}
3636

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

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

43-
throw new UnsupportedSchemeException($dsn, ['api', 'http', 'smtp']);
43+
throw new UnsupportedSchemeException($dsn, ['api', 'http', 'smtp', 'smtps']);
4444
}
4545

4646
public function supports(Dsn $dsn): bool

src/Symfony/Component/Mailer/Bridge/Mailgun/Tests/Transport/MailgunTransportFactoryTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ public function supportsProvider(): iterable
4343
true,
4444
];
4545

46+
yield [
47+
new Dsn('smtps', 'mailgun'),
48+
true,
49+
];
50+
4651
yield [
4752
new Dsn('smtp', 'example.com'),
4853
false,
@@ -74,13 +79,18 @@ public function createProvider(): iterable
7479
new Dsn('smtp', 'mailgun', self::USER, self::PASSWORD),
7580
new MailgunSmtpTransport(self::USER, self::PASSWORD, null, $dispatcher, $logger),
7681
];
82+
83+
yield [
84+
new Dsn('smtps', 'mailgun', self::USER, self::PASSWORD),
85+
new MailgunSmtpTransport(self::USER, self::PASSWORD, null, $dispatcher, $logger),
86+
];
7787
}
7888

7989
public function unsupportedSchemeProvider(): iterable
8090
{
8191
yield [
8292
new Dsn('foo', 'mailgun', self::USER, self::PASSWORD),
83-
'The "foo" scheme is not supported for mailer "mailgun". Supported schemes are: "api", "http", "smtp".',
93+
'The "foo" scheme is not supported for mailer "mailgun". Supported schemes are: "api", "http", "smtp", "smtps".',
8494
];
8595
}
8696

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