Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #33424 [Mailer] Change the DSN semantics (fabpot)
This PR was merged into the 4.4 branch. Discussion ---------- [Mailer] Change the DSN semantics | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | yes | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | n/a | License | MIT | Doc PR | symfony/symfony-docs#12258 I'm not very satisfied with the current DSNs for the Mailer. First, the scheme/protocol should use the provider name, then, there is no way to change the host, which would be nice to debug more easily (using a requestb.in service for instance). Before: ``` smtp://USERNAME:PASSWORD@mailgun http://KEY:DOMAIN@mailgun ``` After: ``` mailgun+smtp://USERNAME:PASSWORD@default mailgun+http://KEY:DOMAIN@default # New mailgun+http://KEY:DOMAIN@somewhere.com:99 ``` SMTP DSNs did not change, but the special sendmail one did: Before: ``` smtp://sendmail ``` After: ``` sendmail+smtp://default ``` And for the `null` transport: Before: ``` smtp://null ``` After: ``` null://null ``` Commits ------- 469c989 [Mailer] Change the DSN semantics
- Loading branch information
Showing
41 changed files
with
704 additions
and
187 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
48 changes: 48 additions & 0 deletions
48
src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesApiTransportTest.php
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Mailer\Bridge\Amazon\Tests\Transport; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Mailer\Bridge\Amazon\Transport\SesApiTransport; | ||
|
||
class SesApiTransportTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider getTransportData | ||
*/ | ||
public function testToString(SesApiTransport $transport, string $expected) | ||
{ | ||
$this->assertSame($expected, (string) $transport); | ||
} | ||
|
||
public function getTransportData() | ||
{ | ||
return [ | ||
[ | ||
new SesApiTransport('ACCESS_KEY', 'SECRET_KEY'), | ||
'ses+api://ACCESS_KEY@email.eu-west-1.amazonaws.com', | ||
], | ||
[ | ||
new SesApiTransport('ACCESS_KEY', 'SECRET_KEY', 'us-east-1'), | ||
'ses+api://ACCESS_KEY@email.us-east-1.amazonaws.com', | ||
], | ||
[ | ||
(new SesApiTransport('ACCESS_KEY', 'SECRET_KEY'))->setHost('example.com'), | ||
'ses+api://ACCESS_KEY@example.com', | ||
], | ||
[ | ||
(new SesApiTransport('ACCESS_KEY', 'SECRET_KEY'))->setHost('example.com')->setPort(99), | ||
'ses+api://ACCESS_KEY@example.com:99', | ||
], | ||
]; | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/Symfony/Component/Mailer/Bridge/Amazon/Tests/Transport/SesHttpTransportTest.php
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Mailer\Bridge\Amazon\Tests\Transport; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Mailer\Bridge\Amazon\Transport\SesHttpTransport; | ||
|
||
class SesHttpTransportTest extends TestCase | ||
{ | ||
/** | ||
* @dataProvider getTransportData | ||
*/ | ||
public function testToString(SesHttpTransport $transport, string $expected) | ||
{ | ||
$this->assertSame($expected, (string) $transport); | ||
} | ||
|
||
public function getTransportData() | ||
{ | ||
return [ | ||
[ | ||
new SesHttpTransport('ACCESS_KEY', 'SECRET_KEY'), | ||
'ses+https://ACCESS_KEY@email.eu-west-1.amazonaws.com', | ||
], | ||
[ | ||
new SesHttpTransport('ACCESS_KEY', 'SECRET_KEY', 'us-east-1'), | ||
'ses+https://ACCESS_KEY@email.us-east-1.amazonaws.com', | ||
], | ||
[ | ||
(new SesHttpTransport('ACCESS_KEY', 'SECRET_KEY'))->setHost('example.com'), | ||
'ses+https://ACCESS_KEY@example.com', | ||
], | ||
[ | ||
(new SesHttpTransport('ACCESS_KEY', 'SECRET_KEY'))->setHost('example.com')->setPort(99), | ||
'ses+https://ACCESS_KEY@example.com:99', | ||
], | ||
]; | ||
} | ||
} |
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
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
Oops, something went wrong.