Jump to content

stop sending when count limit hit


kev wood

Recommended Posts

i have wrote a email distribution system and now i am trying to put a limit on how many emails can be sent.  the limit i want it to stop at is 200 sent messages per day.  i have created this code but i am unsure if it will work.  i have created a if statement with a for loop inside if anyone can see a problem with this please point this out. 

 

if ($sent_mail <= 200 ($limit))
{
// construct mailing list array
$merc_list = explode(",",$merc_mailingList);

// deploy the emails
for($i=0; $i<count($merc_list); $i++){

 

then the message body comes after this section.  the next part of this code is adding the counts together and the else.

 

	} // END for
$sent_mail = $sent_mail + $i;
} // END if condition

else{
include("limit.php");
}

 

 

Link to comment
https://forums.phpfreaks.com/topic/107597-stop-sending-when-count-limit-hit/
Share on other sites

i have changed the code now so it is using a do while loop with a conditional if statement. the code now looks like this

 

$merc_list = explode(",",$merc_mailingList);

// deploy the emails
do($i=0; $i<count($merc_list); $i++){

 

email message comes next.

 

} // END do
while ($i < 200);
if ($send_mail >= 200){
include("limit.php")
} else // add the counts
$send_mail = $send_mail + $i;
}// END if condition

 

what i want to know if the code has been written out correctly and would work as intended if implemented.

the reason i had the if statement evaluating if send mail is greater than or equal to 200 was i only want it to go to the limit page if 200 emails have been sent or if the number of sent emails and the count added to greater is greater than 200.

 

i have looked at the do while statement and i could not find an example with the if statement inside, this is whhy i posted this code here.  do you know where i can find the do while if tutorial?

my code has now been changed and probably not for the last time.

 

$merc_list = explode(",",$merc_mailingList);

if ($send_mail < 200) {

// deploy the emails
for($i=0; $i<count($merc_list); $i++){

// email message body

$send_mail = $send_mail + $i
} // END for
} // END if
else {
include ("limit.php");
} // END else

 

from what i have been looking at this should stop sending out the emails when $send_mail reaches 200. ???

 

i havent used loops inside if statements before.

well one of my piece of code has killed an inbox,  it is just sending the emails to me one after another i have already deleted 1500 odd.  anyone know how to stop it from sending anymore i getting bored of deleting them now.

 

this is also why i needed to know if my code was correct before it was uploaded onto the server.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.