Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.