Jump to content

Email script & waiting time


Thomisback

Recommended Posts

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!";
   }
?>

Link to comment
https://forums.phpfreaks.com/topic/101588-email-script-waiting-time/
Share on other sites

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.

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 ;)

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.