Increase flood limit and flood interval in Drupal 8

Increase flood limit and flood interval in Drupal 8

If you are using Contact form in Drupal 8 and you ever got following error:

"You cannot send more than 5 messages in 1 hour. Try again later"

and if for some reason you want to increase that, then you will want to increase flood limit. However in Drupal 8 just like in Drupal 7 flood control variables are hidden, meaning you can't change them through UI. For Drupal 7 we had a nice Flood control module but it hasn't been ported to Drupal 8 yet.

However you can easily change this variable via following PHP code:

<?php
$flood_limit = 5; //Default value is 5, change to whatever suits you. 
\Drupal::configFactory()->getEditable('contact.settings')
      ->set('flood.limit', $flood_limit)
      ->save();
?>

You can also change flood interval which defaults to 1hour (3600 sec)

<?php 
$flood_interval = 3600; //Default value is 3600sec (1hour), change to whatever suits you
 \Drupal::configFactory()->getEditable('contact.settings')
      ->set('flood.interval', $flood_interval)
      ->save();
?>