Return to Snippet

Revision: 7746
at March 12, 2009 12:41 by benphelps


Updated Code
<?php

  set_time_limit(0); // this will keep the script from stopping if it takes longer then 30 seconds, must have this here
  $emailaddress = file("email-list.txt"); // load from a flat file, assuming 1 email per line in the file
  $emailsubject = "This is a sample subject!";
  $emailbody = file_get_contents("email.html");
  $fromaddress = "[email protected]";
  $i = count($emailaddress);
  $z = 0;
  
  // here we check how many  email address's we have, if its is 0, then we don't start the email function
  if ($i != 0)
    {// start if
      
      // Lets loop until we reach the count from email address arrar
      while ($i != $z)
        {// start while
          
          // here we send the email to the varables from above, using the email array incrament
          mail($emailaddress[$z], $emailsubject, $emailbody, "From: " .$fromaddress. "\nX-Mailer: PHP 4.x");
          
          // lets echo out that the email was sent
          echo $z + 1 . " out of " . $i . " emails sent. (" . $emailaddress[$z] . ")<br>";
          
          // increment the array one, so we get a new email address from the array
		  ++$z;
		  
        }// end while   
		
      }//end if
      
   else
     {//start else
       
       // we echo out that no emails where found in the array and end the script
       echo "Warning: No emails in array.";
	   	 
     }// end else
	 
?>

Revision: 7745
at March 12, 2009 12:40 by benphelps


Updated Code
<?php

  set_time_limit(0); // this will keep the script from stopping if it takes longer then 30 seconds, must have this here
  $emailaddress = file("email-list.txt"); // load from a flat file, amusing 1 email per line in the file
  $emailsubject = "This is a sample subject!";
  $emailbody = file_get_contents("email.html");
  $fromaddress = "[email protected]";
  $i = count($emailaddress);
  $z = 0;
  
  // here we check how many  email address's we have, if its is 0, then we dont start the email function
  if ($i != 0)
    {// start if
      
      // Lets loop until we reach the count from email address arrar
      while ($i != $z)
        {// start while
          
          // here we send the email to the varables from above, using the email array incrament
          mail($emailaddress[$z], $emailsubject, $emailbody, "From: " .$fromaddress. "\nX-Mailer: PHP 4.x");
          
          // lets echo out that the email was sent
          echo $z + 1 . " out of " . $i . " emails sent. (" . $emailaddress[$z] . ")<br>";
          
          // increment the array one, so we get a new email address from the array
		  ++$z;
		  
        }// end while   
		
      }//end if
      
   else
     {//start else
       
       // we echo out that no emails where found in the array and end the script
       echo "Warning: No emails in array.";
	   	 
     }// end else
	 
?>

Revision: 7744
at August 10, 2008 16:18 by benphelps


Initial Code
<?php

  set_time_limit(0); // this will keep the script from stoping if it takes longer then 30 seconds, must have this here
  $emailaddress = file("email-list.txt"); // load from a flat file, asuming 1 email per line in the file
  $emailsubject = "This is a sample subject!";
  $emailbody = file_get_contents("email.html");
  $fromaddress = "[email protected]";
  $i = count($emailaddress);
  $z = 0;
  
  // here we check how many  email address's we have, if its is 0, then we dont start the email function
  if ($i != 0)
    {// start if
      
      // Lets loop until we reach the count from email address arrar
      while ($i != $z)
        {// start while
          
          // here we send the email to the varables from above, using the email array incrament
          mail($emailaddress[$z], $emailsubject, $emailbody, "From: " .$fromaddress. "\nX-Mailer: PHP 4.x");
          
          // lets echo out that the email was sent
          echo $z + 1 . " out of " . $i . " emails sent. (" . $emailaddress[$z] . ")<br>";
          
          // incrament the array one, so we get a new email address from the array
		  ++$z;
		  
        }// end while   
		
      }//end if
      
   else
     {//start else
       
       // we echo out that no emails where found in the array and end the script
       echo "Warning: No emails in array.";
	   	 
     }// end else
	 
?>

Initial URL
http://phelps.impactwow.com

Initial Description


Initial Title
Loop email reading flat file

Initial Tags
email, file

Initial Language
PHP