Thomisback Posted April 17, 2008 Share Posted April 17, 2008 Hey I have got an email script which emails a .txt with about 282K email addresses, I now want to set a waiting time between each e-mail sent, does anyone know how to do this? Thanks in advance! My script: <?php // read the list of emails from the file. $email_list = file("elist.txt"); // count how many emails there are. $total_emails = count($email_list); // go through the list and trim off the newline character. for ($counter=0; $counter<$total_emails; $counter++) { $email_list[$counter] = trim($email_list[$counter]); } // implode the list into a single variable, put commas in, apply as $to value. $to = implode(",",$email_list); $subject = "My email test."; $message = "Hello, how are you?"; if ( mail($to,$subject,$message) ) { echo "The email has been sent!"; } else { echo "The email has failed!"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/101588-email-script-waiting-time/ Share on other sites More sharing options...
jonsjava Posted April 17, 2008 Share Posted April 17, 2008 <?php sleep(3); ?> would pause it for 3 seconds Quote Link to comment https://forums.phpfreaks.com/topic/101588-email-script-waiting-time/#findComment-519703 Share on other sites More sharing options...
Thomisback Posted April 17, 2008 Author Share Posted April 17, 2008 Thanks, but how could I do that between each e-mail? Quote Link to comment https://forums.phpfreaks.com/topic/101588-email-script-waiting-time/#findComment-519710 Share on other sites More sharing options...
discomatt Posted April 17, 2008 Share Posted April 17, 2008 282K emails? Is this a solicited mailing? I'd love to help, but not if I'm gonna wind up with one of your emails in my inbox Quote Link to comment https://forums.phpfreaks.com/topic/101588-email-script-waiting-time/#findComment-519713 Share on other sites More sharing options...
laffin Posted April 17, 2008 Share Posted April 17, 2008 My thoughts exactly, when i seen this post. Quote Link to comment https://forums.phpfreaks.com/topic/101588-email-script-waiting-time/#findComment-519715 Share on other sites More sharing options...
Thomisback Posted April 17, 2008 Author Share Posted April 17, 2008 Don't worry lol, these are all from my website from people who agreed to my ToS, it's only a newsletter. Quote Link to comment https://forums.phpfreaks.com/topic/101588-email-script-waiting-time/#findComment-519716 Share on other sites More sharing options...
jonsjava Posted April 17, 2008 Share Posted April 17, 2008 holy underwear, batman! You are doing this the crazy way! go to http://sourceforge.net/projects/mailgroup and download my mail group solution application. it sends each email as a single email to a single recipient. The RFC standards for email is no more than 300 recipients unless you are a listserv. Quote Link to comment https://forums.phpfreaks.com/topic/101588-email-script-waiting-time/#findComment-519720 Share on other sites More sharing options...
Thomisback Posted April 17, 2008 Author Share Posted April 17, 2008 Haha, thank you going to have a look at it now! Quote Link to comment https://forums.phpfreaks.com/topic/101588-email-script-waiting-time/#findComment-519721 Share on other sites More sharing options...
discomatt Posted April 17, 2008 Share Posted April 17, 2008 You have quite the newsletter! <?php // Set no max execution time set_time_limit(0); // read the list of emails from the file. $email_list = file("elist.txt"); $subject = "My email test."; $message = "Hello, how are you?"; foreach ($email_list as $email) { if ( mail( trim($email),$subject,$message ) ) echo "Mail sent to $email successfully<br>\n"; else echo "Could not send mail to $email<br>\n"; // Pause for 3 seconds sleep(3); } ?> Keep in mind, 3 seond delay * 282k emails = almost 10 days to run the script Quote Link to comment https://forums.phpfreaks.com/topic/101588-email-script-waiting-time/#findComment-519736 Share on other sites More sharing options...
jonsjava Posted April 17, 2008 Share Posted April 17, 2008 my thought exactly. that's why I recommended the script. It sends out as fast as it can process the data from the database. 1 at a time, and because it has opt-in/opt-out functionality, he won't need to worry about getting hit with a spam fine. Quote Link to comment https://forums.phpfreaks.com/topic/101588-email-script-waiting-time/#findComment-519851 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.