In want replace deprecated SwiftMailer v6.2.5 with new Symfony/Mailer v6.x. SwiftMailer have a AntiFlood Plugin
$mailer = new Swift_Mailer($transport);
$mailer->registerPlugin(new Swift_Plugins_AntiFloodPlugin(100, 5));
I can't find this for Symfony/Mailer. Does this function(plugin) not yet exist or is this now solved in a completely different way?
Symfony Mailer 6.2 (current) has some parameters that might help to get similar approach as Swifmailer's AntiFlood plugin.
First, lets see how AntiFlood works. According to plugin's docs:
If we see official documentation of Symfony Mailer component. We can see some parameters that do exactly the same thing:
restart_threshold
(Introduced in Symfony 5.2)The maximum number of messages to send before re-starting the transport.
restart_threshold_sleep
(Introduced in Symfony 5.2)The number of seconds to sleep between stopping and re-starting the transport.
Here is an example using both parameters together:
There are two more options in case you don't want to restart the transport, but instead just limit the amount of emails sent per second. See the documentation linked above if that's the case.