is this possible to do?

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++){

// email body inside here

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

i have created an email distribution system for creating and sending out newsletters. i want to be able to limit the user to only be able to send out 200 emails per day. the reason for this is the highest number of emails some servers will allow to be sent each day is 200.

also to try and stop this from being used for spamming.

here is what i would use:


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

$send = true;
$i = 0;
while ($i < count($merc_list) && send = true) {
  //send emails
  if ($i > 200) {
    $send = false;


maybe not exactly what you need but i think you will get it and be able to manipulate it to your needs.

the code above didnt do all i needed so i have been away working on the solution still not sure if i have it tho.

my code now looks like this

$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

is the code i have used valid

no it is not.

has anyone ever written a piece of code like this before? probably people have just not the ones looking at this.

just to clarify my problem.

i need to be able to stop the emails being sent out when the counter reaches 200. there is already a count set up so that it counts the number of emails sent out, so i need to put some sort of an if statement in to stop it from sending the mail.

everything i have tried has failed.

Doesn't this work ?

$merc_list = explode(",",$merc_mailingList);
for($i=0; $i<count($merc_list); $i++) {
 if($i <=200) {
 	//send mail 
 } else {
 	//you can't send any more mails today
echo "200 out of ".count($merc_list)." mails have been sent today !";	

that looks like it has done the trick thanks for the reply. just having a bit of a problem with the sql i am adding to it.

This article has been dead for over six months. Start a new discussion instead.