Skip to content

Commit 9ce7d5d

Browse files
sonnymiltonfabpot
authored andcommitted
[Mailer][Sendgrid] Add support for global region
1 parent 5eae900 commit 9ce7d5d

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)