Author Topic: Need to Throttle SMTP Email, one every 19 seconds  (Read 4577 times)

prepress forums

  • Posts: 24
    • View Profile
    • http://prepressforum.com
Need to Throttle SMTP Email, one every 19 seconds
« on: May 08, 2007, 12:14:12 pm »
In admin.php you will find the domail() function.

Look for this line:

Code:
   
Code: [Select]
} else {
     // use php mail()


Above the else statement is the SMTP loop. You can place your delays right before the text above.

the $y variable contains the current msg number. To delay 19 seconds every 1 emails try this:

Code:
Code: [Select]
if(($y % '1')==0 && $y <> sizeof($sendq)) sleep(19);

OK, I Found the line similar I think but my code does not look like the other examples in these older posts.  I have adjusted the timer code above to delay every 1 message, 19 seconds, does my edit of the delay code (above) look correct?
--
JP

http://prepressforum.com - corvette-forum - http://free-preflight.com - http://printing-quote.us - http://destin-florida-hotel.com - Destin Florida Forum
corvette forum, corvette z06 forum, corvette c6 forum, c5 corvette forum, prepress forum, postcards, brochures, destin florida hotels

prepress forums

  • Posts: 24
    • View Profile
    • http://prepressforum.com
Need to Throttle SMTP Email, one every 19 seconds
« Reply #1 on: May 08, 2007, 12:39:16 pm »
OK, took a stab at it but got this error.  


Parse error: syntax error, unexpected T_STRING in /home/graphic/public_html/ListMail/admin.php on line 1711

So, I put back in the original admin.php file.  Here's what I have in the file I tried to edit.  Must be something wrong, did I need to put 1900000 instead of 19, I saw another post that just had a "25" for the delay of 25 seconds.  So, I figured if it was in whole seconds that "19" would be fine?

That's wrong with this?

Code: [Select]

        if($smtp_debug) logwrite($bugf,"> SENT DATA\r\n");
        fputs($ssock, $themesg."\r\n.\r\n");
        $srvmsg = fgets($ssock, 1024);
        $errmsg .= $srvmsg;
        if($smtp_debug) logwrite($bugf,$srvmsg);
        $lastmsg = substr($srvmsg, 0, 3);
        if ($lastmsg <> "250") $error = 1; else $error = '';
        }
      }      
   if(($y % '1')==0 && $y <> sizeof($sendq)) sleep(19);
     }
   
     } else {
     // use php mail()
      $body = str_replace("\r\n","\n",$body);
--
JP

http://prepressforum.com - corvette-forum - http://free-preflight.com - http://printing-quote.us - http://destin-florida-hotel.com - Destin Florida Forum
corvette forum, corvette z06 forum, corvette c6 forum, c5 corvette forum, prepress forum, postcards, brochures, destin florida hotels

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Need to Throttle SMTP Email, one every 19 seconds
« Reply #2 on: May 08, 2007, 01:47:28 pm »
I believe the error is because of dividing by '1' (string) instead of 1 (integer).

To delay every message you could simply use this:
Code: [Select]
if($y <> sizeof($sendq)) sleep(19);
I don't recommend using the % division remainder operator with a value less than 2.
Code: [Select]
if(($y % 2)==0 && $y <> sizeof($sendq)) sleep(10);
Regards
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Need to Throttle SMTP Email, one every 19 seconds
« Reply #3 on: May 08, 2007, 01:59:12 pm »
Also as you noted in another thread the brackets may be off.  Here is where the code should go:
Code: [Select]
       if ($lastmsg <> "250") $error = 1; else $error = '';
       }
      }
      // right here
      if($y <> sizeof($sendq)) sleep(19);
     } else {
     // use php mail()

Regards
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

prepress forums

  • Posts: 24
    • View Profile
    • http://prepressforum.com
Need to Throttle SMTP Email, one every 19 seconds
« Reply #4 on: May 08, 2007, 02:00:13 pm »
OK, thanks, that compiled and looks like I can try it out.  Please see my comments about the other post that has these examples, the use of code is not consistant and was probably one reason that none of it worked for me.

After getting your statement and starting over from fresh admin.php file, i did it just like a phpBB mod.  I inserted that line on line above code you stated, BAM, that compiles.  Now I will see if it all works to throttle the mail correctly.  Thanks for the help dean.
--
JP

http://prepressforum.com - corvette-forum - http://free-preflight.com - http://printing-quote.us - http://destin-florida-hotel.com - Destin Florida Forum
corvette forum, corvette z06 forum, corvette c6 forum, c5 corvette forum, prepress forum, postcards, brochures, destin florida hotels

prepress forums

  • Posts: 24
    • View Profile
    • http://prepressforum.com
How to Throttle Email by SMTP with ListMail Pro
« Reply #5 on: May 08, 2007, 02:52:13 pm »
Dean,  Thank you so much again for the fast decisive help.  It's great and I'm so glad that I invested in the software.  I am going to wrap this with some really clear instruction for the next person to try this.  In case they are to get confused like me.

Open File

admin.php

FIND


Code: [Select]

} else {
     // use php mail()


Insert this line, creating a new line of code immediately
above the line with else.  


Code: [Select]

      if($y <> sizeof($sendq)) sleep(19);


When completed should look just like this example below,
new line is highlighted:




This is 19 seconds.  That's because my host wants me to
limit to under 200 emails per hour.  19 seconds = 189/hr.

To change your interval just do the math and change that
delay from 19 seconds to whatever is best to throttle
your email output.
--
JP

http://prepressforum.com - corvette-forum - http://free-preflight.com - http://printing-quote.us - http://destin-florida-hotel.com - Destin Florida Forum
corvette forum, corvette z06 forum, corvette c6 forum, c5 corvette forum, prepress forum, postcards, brochures, destin florida hotels

ifsbos

  • Posts: 16
    • View Profile
Need to Throttle SMTP Email, one every 19 seconds
« Reply #6 on: October 23, 2008, 12:52:54 pm »
After adding the change to admin.php ...

Is there anything that needs to be added in the configuration for SMTP?  
It would be really nice if someone could post a screen shot of the system configuration for say

400-500 emails per hour  which is most hosts allow.

I have added the change to the admin.php and the script is running fine.
This is what it says, stopping at 350
Sending 350 to server:  of 8799.

Average speed: 14.71 per second. 52956 per hour.
So something is not set up right I think.

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Need to Throttle SMTP Email, one every 19 seconds
« Reply #7 on: October 23, 2008, 01:02:51 pm »
This manual change to admin.php should be all you need to throttle SMTP email, and the counter/stats should reflect the change.

Are you sure you added it just above the line indicated? ie:
Code: [Select]
usleep(720000); // delay .72s per email = 5000/hr
} else {
     // use php mail()
« Last Edit: June 22, 2017, 06:09:28 pm by DW »
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting