We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

php sleep or batch setup - MessageAll | Forum

dave Leader
dave Jun 1 '13

Hi, nice job on the plugin, just used it the first time and worked great with one exception, it went over the number of emails per hour limit.   I know on my old script for every 70 emails sent i had a php sleep http://php.net/manual/en/function.sleep.php  set up for 3 min and it seemed to work great.  

 

You might consider something like that or some way to batch them in 50 row increments maybe.   I will try to see what i can do and will post that result here.

 

Nice job, please also let me know if you do something on this so i dont work on this if not needed...

 

:)  peace 

Purusothaman Ramanujam
This is not in the scope of this plugin. The Oxwall Email library is the one should be modified to limit the number of emails sent per hour.

Thanks for your kind words and letting me know your concern.
dave Leader
dave Jun 2 '13
fair enough :)
dave Leader
dave Jun 2 '13

Yep quite right, just as a test i did this in ow_plugins/msgall/controllers/admin.php

i basically just put an if statement  inside the foreach loop that was there to check for the number of emails. 

 

But you were right this did not work and it still sent all.  So i will check the library :)  Thanks 

 

 

   // added for sleep code
           $s = 1

          foreach ($allUsers as $user)
          {
           
            //as long as it is under 70 emails then process as normal
            if($s < 70)
            {         
           

               if($user->id != $admin)
               {
                $subject_new = str_replace("{user_name}",BOL_UserService::getInstance()->getDisplayName($user->id),$subject);
                $message_new = str_replace("{user_name}",BOL_UserService::getInstance()->getDisplayName($user->id),$message);
                $conversation = MAILBOX_BOL_ConversationService::getInstance()->createConversation($admin, $user->id, $subject_new , $message_new );
               }

 

             $s++;   //increment $s

 

           }else{
                 sleep(90); //sleep 90sec (1.5 min)         
                 $s=1; //reset $s
                }//close else


          }// close foreach          

 

Purusothaman Ramanujam
Yeah.. Oxwall has a cron based job which sends any pending email in the queue..
This topic is locked
You do not have permission to reply this topic