Jump to content

limiting number of emails sent


SilentQ-noob-

Recommended Posts

Hi,

I've got an email system that works without any problems, but what I want to do is limit the amount of emails sent out at one time.

Right now what happens is user emails are pulled from a table, then once an email has been sent to their e-mail address, the row is deleted from the table with the users.

I want to be able to control how many emails are sent out at one time, so for example if I select 50 users to send an email to: It send out the emails in groups of 25.

The reason I want to do  it this way is that I want to run a scheduled task, so once I have hundreds of users I want to set it up so that if several hundred or even thousands of people are receiving an email notification for example, the email is sent out in sets of 100(or any number I choose) at the times that I set the scheduled task to.

 

 

 

This is the main part of the emailing code I have now- its works without any problems, but sends out all the emails at once.

<?  $send_info2 = mysql_query("
	SELECT	from_name, from_email, subject, content, rec_total
	FROM 	///EMAIL TABLE
	WHERE	id = $email_id
	LIMIT	0, 1
	"); 
	while($row2 = mysql_fetch_array($send_info2)) {
		$from_name 	= $row2['from_name'];
		$from_email 	= $row2['from_email'];
		$subject	     	= $row2['subject'];
		$message	= $row2['content'];
		$rec_total	= $row2['rec_total'];
		$rec_sent	= $row2['rec_sent'];
		$from =  $from_name."<".$from_email.">";
		ini_set("sendmail_from",$from);
		$headers = "From: ".$from."\r\n". "Content-Type: text/html; format=flowed\r\n". "MIME-Version: 1.0\n". "Content-Transfer-Encoding: 8bit\n". "X-Mailer: PHP\n";
		mail($to,$subject,$message,$headers); 
}	
?>

Any input is welcomed and appreciated. Thanks

Link to comment
https://forums.phpfreaks.com/topic/87617-limiting-number-of-emails-sent/
Share on other sites

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.