Skip to content

Commit 9b36ddc

Browse files
committed
feature symfony#61758 [Mailer][Sendgrid] Add support for global region (sonnymilton)
This PR was squashed before being merged into the 7.4 branch. Discussion ---------- [Mailer][Sendgrid] Add support for `global` region | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | Fix symfony#61706 | License | MIT This PR ensures that when the `global` region is provided to `SendgridSmtpTransport`, the correct host `smtp.sendgrid.net` is used. Previously, passing `region=global` resulted in the host being built as `smtp.global.sendgrid.net`, which does not exist. ### Why - DSNs like `sendgrid+smtp://KEY@default?region=global` failed to connect. - SendGrid documentation specifies that the "global" region is just `smtp.sendgrid.net` (same as when no region is provided). ### How - Updated `SendgridSmtpTransport` to special-case the `global` region. - Added a unit test to cover this scenario. Commits ------- 9ce7d5d [Mailer][Sendgrid] Add support for `global` region
2 parents 5eae900 + 9ce7d5d commit 9b36ddc

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/Symfony/Component/Mailer/Bridge/Sendgrid/CHANGELOG.md

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

77
* Add support for suppression groups via `SuppressionGroupHeader`
8+
* Add support for `global` region
89

910
7.2
1011
---

src/Symfony/Component/Mailer/Bridge/Sendgrid/Tests/Transport/SendgridSmtpTransportTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ public static function getTransportData()
3737
new SendgridSmtpTransport('KEY', null, null, 'eu'),
3838
'smtps://smtp.eu.sendgrid.net',
3939
],
40+
[
41+
new SendgridSmtpTransport('KEY', null, null, 'global'),
42+
'smtps://smtp.sendgrid.net',
43+
],
4044
];
4145
}
4246

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ class SendgridSmtpTransport extends EsmtpTransport
2727
{
2828
public function __construct(#[\SensitiveParameter] string $key, ?EventDispatcherInterface $dispatcher = null, ?LoggerInterface $logger = null, private ?string $region = null)
2929
{
30-
parent::__construct(null !== $region ? \sprintf('smtp.%s.sendgrid.net', $region) : 'smtp.sendgrid.net', 465, true, $dispatcher, $logger);
30+
$host = 'smtp.sendgrid.net';
31+
32+
if (null !== $region && 'global' !== $region) {
33+
$host = \sprintf('smtp.%s.sendgrid.net', $region);
34+
}
35+
36+
parent::__construct($host, 465, true, $dispatcher, $logger);
3137

3238
$this->setUsername('apikey');
3339
$this->setPassword($key);

0 commit comments

Comments
 (0)