Random pause in-between mailing?

Discussion in 'General discussions' started by Joseph, Sep 10, 2019.

  1. Joseph

    Joseph Member

    Joined:
    Mar 12, 2015
    Messages:
    77
    Likes Received:
    3
    S.E:
    2019-10-25 20:28:14
    L.T:
    Regular
    L.C:
    2
    Is there a way to random pause for each email sent?

    Right now there's an option of setting pause in terms of milliseconds in Server settings. The emailing is constant at each interval.

    I'm looking at randomly pause between, say, 5 seconds to 60 seconds between each email sent.

    Is there a way to do it?
     
  2. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,289
    Likes Received:
    2,391
    Here's and example for sleeping randomly for 0 to 10 sec:
    PHP:
    // apps/init-custom.php
    Yii::app()->hooks->addAction('console_command_send_campaigns_after_send_to_subscriber', function(){
        
    sleep(rand(010));
    });
     
  3. Joseph

    Joseph Member

    Joined:
    Mar 12, 2015
    Messages:
    77
    Likes Received:
    3
    S.E:
    2019-10-25 20:28:14
    L.T:
    Regular
    L.C:
    2
    Thanks for the script. So for this script, it will add on a random seconds pause after the configured "Pause after send" in Server?

    That means, in Backend->Server->Pause after send if I put "2000000", the above script will add another random X seconds to this "2000000" right?
     
  4. Joseph

    Joseph Member

    Joined:
    Mar 12, 2015
    Messages:
    77
    Likes Received:
    3
    S.E:
    2019-10-25 20:28:14
    L.T:
    Regular
    L.C:
    2
    Sorry, for the above code, which file do I place that code? I can't find init-custom.php in /apps/, only init.php. Is it an additional file? Or add a code in the init.php?
     
  5. laurentiu

    laurentiu Active Member Staff Member

    Joined:
    Mar 13, 2018
    Messages:
    263
    Likes Received:
    33
    @Joseph - You need to create init-custom.php file.
     
  6. Joseph

    Joseph Member

    Joined:
    Mar 12, 2015
    Messages:
    77
    Likes Received:
    3
    S.E:
    2019-10-25 20:28:14
    L.T:
    Regular
    L.C:
    2
    Thanks
     

Share This Page