Skip to content

Commit 397abb6

Browse files
committed
feature symfony#46315 [Mailer] max_per_second option configurable via DSN (gassan)
This PR was merged into the 6.2 branch. Discussion ---------- [Mailer] `max_per_second` option configurable via DSN | Q | A | ------------- | --- | Branch? | 6.2 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | - | License | MIT | Doc PR | symfony/symfony-docs#16800 This option is available since 5.1, but it was impossible to configure it by dsn. Commits ------- a377f2e made max_per_second option configurable by dsn
2 parents 5d9b6d2 + a377f2e commit 397abb6

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Symfony/Component/Mailer/Tests/Transport/Smtp/EsmtpTransportFactoryTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ public function createProvider(): iterable
116116
$transport,
117117
];
118118

119+
$transport = new EsmtpTransport('example.com', 465, true, $eventDispatcher, $logger);
120+
$transport->setMaxPerSecond(2.0);
121+
122+
yield [
123+
new Dsn('smtps', 'example.com', '', '', 465, ['max_per_second' => '2']),
124+
$transport,
125+
];
126+
119127
$transport = new EsmtpTransport('example.com', 465, true, $eventDispatcher, $logger);
120128
$transport->setRestartThreshold(10, 1);
121129

src/Symfony/Component/Mailer/Transport/Smtp/EsmtpTransportFactory.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ public function create(Dsn $dsn): TransportInterface
5252
$transport->setLocalDomain($localDomain);
5353
}
5454

55+
if (null !== ($maxPerSecond = $dsn->getOption('max_per_second'))) {
56+
$transport->setMaxPerSecond((float) $maxPerSecond);
57+
}
58+
5559
if (null !== ($restartThreshold = $dsn->getOption('restart_threshold'))) {
5660
$transport->setRestartThreshold((int) $restartThreshold, (int) $dsn->getOption('restart_threshold_sleep', 0));
5761
}

0 commit comments

Comments
 (0)