Skip to content

Commit

Permalink
feature symfony#46315 [Mailer] max_per_second option configurable v…
Browse files Browse the repository at this point in the history
…ia 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
  • Loading branch information
fabpot committed Jul 20, 2022
2 parents 5d9b6d2 + a377f2e commit 397abb6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ public function createProvider(): iterable
$transport,
];

$transport = new EsmtpTransport('example.com', 465, true, $eventDispatcher, $logger);
$transport->setMaxPerSecond(2.0);

yield [
new Dsn('smtps', 'example.com', '', '', 465, ['max_per_second' => '2']),
$transport,
];

$transport = new EsmtpTransport('example.com', 465, true, $eventDispatcher, $logger);
$transport->setRestartThreshold(10, 1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public function create(Dsn $dsn): TransportInterface
$transport->setLocalDomain($localDomain);
}

if (null !== ($maxPerSecond = $dsn->getOption('max_per_second'))) {
$transport->setMaxPerSecond((float) $maxPerSecond);
}

if (null !== ($restartThreshold = $dsn->getOption('restart_threshold'))) {
$transport->setRestartThreshold((int) $restartThreshold, (int) $dsn->getOption('restart_threshold_sleep', 0));
}
Expand Down

0 comments on commit 397abb6

Please sign in to comment.