-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "set schema to smtps if MAIL_ENCRYPTION === tls" (#53863)
* Revert "adjust MailManager to detect if smtp or smtps is needed by checking e…" This reverts commit c07f426. * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * Update comment Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> --------- Signed-off-by: Mior Muhammad Zaki <[email protected]>
- Loading branch information
Showing
2 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,71 @@ public function testMailUrlConfig($scheme, $port) | |
$this->assertSame('127.0.0.2', $transport->getStream()->getHost()); | ||
$this->assertSame($port, $transport->getStream()->getPort()); | ||
$this->assertSame($port === 465, $transport->getStream()->isTLS()); | ||
|
||
if (method_exists($transport, 'isAutoTls')) { | ||
// Only available from Symfony Mailer 7.1 | ||
$this->assertTrue($transport->isAutoTls()); | ||
} | ||
} | ||
|
||
#[TestWith([null, 5876])] | ||
#[TestWith([null, 465])] | ||
#[TestWith(['smtp', 25])] | ||
#[TestWith(['smtp', 2525])] | ||
#[TestWith(['smtps', 465])] | ||
#[TestWith(['smtp', 465])] | ||
public function testMailUrlConfigWithAutoTls($scheme, $port) | ||
{ | ||
$this->app['config']->set('mail.mailers.smtp_url', [ | ||
'scheme' => $scheme, | ||
'url' => "smtp://usr:[email protected]:{$port}?auto_tls=true", | ||
]); | ||
|
||
$mailer = $this->app['mail.manager']->mailer('smtp_url'); | ||
$transport = $mailer->getSymfonyTransport(); | ||
|
||
$this->assertInstanceOf(EsmtpTransport::class, $transport); | ||
$this->assertSame('usr', $transport->getUsername()); | ||
$this->assertSame('pwd', $transport->getPassword()); | ||
$this->assertSame('127.0.0.2', $transport->getStream()->getHost()); | ||
$this->assertSame($port, $transport->getStream()->getPort()); | ||
$this->assertSame($port === 465, $transport->getStream()->isTLS()); | ||
|
||
if (method_exists($transport, 'isAutoTls')) { | ||
// Only available from Symfony Mailer 7.1 | ||
$this->assertTrue($transport->isAutoTls()); | ||
} | ||
} | ||
|
||
#[TestWith([null, 5876])] | ||
#[TestWith([null, 465])] | ||
#[TestWith(['smtp', 25])] | ||
#[TestWith(['smtp', 2525])] | ||
#[TestWith(['smtps', 465])] | ||
#[TestWith(['smtp', 465])] | ||
public function testMailUrlConfigWithAutoTlsDisabled($scheme, $port) | ||
{ | ||
$this->app['config']->set('mail.mailers.smtp_url', [ | ||
'scheme' => $scheme, | ||
'url' => "smtp://usr:[email protected]:{$port}?auto_tls=false", | ||
]); | ||
|
||
$mailer = $this->app['mail.manager']->mailer('smtp_url'); | ||
$transport = $mailer->getSymfonyTransport(); | ||
|
||
$this->assertInstanceOf(EsmtpTransport::class, $transport); | ||
$this->assertSame('usr', $transport->getUsername()); | ||
$this->assertSame('pwd', $transport->getPassword()); | ||
$this->assertSame('127.0.0.2', $transport->getStream()->getHost()); | ||
$this->assertSame($port, $transport->getStream()->getPort()); | ||
|
||
if (method_exists($transport, 'isAutoTls')) { | ||
// Only available from Symfony Mailer 7.1 | ||
$this->assertFalse($transport->isAutoTls()); | ||
$this->assertSame($port === 465 && $scheme !== 'smtp', $transport->getStream()->isTLS()); | ||
} else { | ||
$this->assertSame($port === 465, $transport->getStream()->isTLS()); | ||
} | ||
} | ||
|
||
public function testBuild() | ||
|