Jump to content

Recommended Posts

<?php

$emails = array("email1@site.com", "email2@site.com");

$message = "This email was sent by PHP!";

$from = "noreply@mysite.com";

$subject = "Sent from PHP";

foreach($emails as $email) {
$headers = "From: {$from}";
mail($email, $subject, $message, $headers);
echo "Sent to {$email}<br />\n";
}

?>

I have no problem sending the email. I was thinking more like lets say

I must send 1000 emails

 

so First I send 100 and then 100 and so on. Does the functions sleep() helps with this?

 

sending 100 and then

 

sleep(5) // 5 seconds

 

and then start again with the next set of emails until they are done

Everytime you refresh the page it will re-parse so unless you have something like a DB table to confirm which ones sent and which ones didn't you won't be able to.

 

You *may* be able to store them all as one huge array in a session variable but that would be pretty inefficent.

 

Maybe if you explained why exactly you want to take a break between e-mailing?

Use ini_set() to set the maximum execution time, and just loop through all of them. It won't timeout as long as it doesn't hit a neverending loop.

 

Exactly, like I said above. My server has a maximum execution time of 30 seconds, however I have a script that runs for a little of an hour. Execution time only exists when it hits a neverending loop and thus hangs executing that one function for the preset length of time.

 

To e-mail 1 million subscribers will take quite a while, but the PHP script won't timeout as long as it is pogrammed correctly without any never-ending loops.

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.