![]() |
|
? |
![]() PHP FAQ PHP Articles PHP Help Bulletin Board PHP Manual (NEW!) First Time PHP'ers Help with programming Sql assignment help PHP Homework Help C# Help
|
? |
|
||||||||||||||||||||||||||||||||||||||||
?Reply To This Message | |||||||||||||||||||||||||||||||||||||||||||
?Your Name: | |||||||||||||||||||||||||||||||||||||||||||
?Your Email: | |||||||||||||||||||||||||||||||||||||||||||
?Subject: | |||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
Email replies to this thread, to the address above. | |||||||||||||||||||||||||||||||||||||||||||
??wrote: > > is this an individually addressed email or ca it go to > multiple people at once? > > will assume group of 50 people at once > > > > $sql="select name, email from people_table"; > > $result = mysql_query($sql) or die ("Can't connect because > ".mysql_error()); > > if (!$result){ > echo "there was an error. please hit the back key and try > again"; > }else{ > > //go thru the list and create the email > > //create counters > $x=1; $g=0; > > //set the destination > $to=""; > > //figure out the no of emails to be sent and the no of > groups > $num_elements = mysql_num_rows($result); > > //figure out the total number of groups of 50 emails > $total_email_groups = floor($num_elements/50); > > //figure out the remainder of emails to send in last group > $total_remainder= $num_elements -($total_email_groups * > 50); > > > while ($rows=mysql_fetch_array($result)){ > > $name=$rows['name']; //required for individual msg > $email=$rows['email']; //get the email > > if ($x==1){ > //only need to set the below once > $subject = "Whatever my subject is"; > $message = "body of message here(can be html with > appropriate headers)"; > > //add the headers to create the html email > $headers = "MIME-Version: 1.0\n"; > $headers .= "Content-type: text/html; > charset=iso-8859-1\n"; > $headers .= "From: $your_name<$email>\nX-Mailer: > PHP Automated Mailer"; > }//end if > > //start the loop to send 50 emails at a time or last > group > if > ($x==50)||(($g==$total_email_groups)&&{$x==$total_remainder)){ > //if 50 email destinations then send > mail ($to, $subject, $message, $headers); > sleep(300); //wait 5 min to allow email > server to send out the emails > $x=1; //reset the email counter > $to=""; //reset destination > $g++; //increase the group counter > > }else{ > $to.=$email.";"; //add the email to the list > $x++; > } > > }//end while > > }//end if > > needs to be tested ">??![]() |