Move the ->Send outside the loop?
And fix your indentation to something sane, so you know what's going
on in your script.
[Apologies if mail transport messed it up...]
On Thu, October 12, 2006 8:30 am, Ross wrote:
> Why does this send multiple times. I want it to loop through and send
> it
> once.
>
>
> -----------------------------------------------------------------------------------------
> <?php
> session_start();
> include "check_login.php";
>
> global $PHP_SELF, $mail_text, $search_string;
>
> if(!isset($_POST['area'])){ $_POST['area']='a'; $area=
> $_POST['area'];}
>
> if(!isset($_POST['filter'])){ $_POST['filter']="sname"; $filter =
> $_POST['filter'];}
>
>
>
> if (isset($SUBMIT)){
>
> $mail_body = "this is the body";
>
> include("mailer/class.phpmailer.php");
>
> $mail = new PHPMailer();
> $mail->Mailer = "mail";
> // telling the class to use SMTP
> $mail->IsHTML(true);
> $mail->Host = "mail.scottishsocialnetworks.org"; // SMTP server
> $mail->FromName = "Scottish Social Networks";
> $mail->From = "[EMAIL PROTECTED]";
>
> //set up the mail loop
>
>
>
>
> $addresses = array();
> $addresses = explode(",", $mail_to);
>
> $mail->AddAttachment($userfile, $_FILES['userfile']['name']);
> $mail->Subject = $mail_subject;
> $mail->Body = nl2br($mail_body);
> $mail->WordWrap = 50;
>
> for($i = 0; $i < count($addresses); $i++)
> {
> $mail->AddAddress($addresses[$i]);
> $mail->Send();
>
> }
>
>
>
>
>
>
>
>
> }
>
>
>
>
>
>
>
>
>
>
> ?>
>
>
> <?php
> //include ('authorise.php');
> include ('connect.php');
> global $one, $two, $three, $recipients, $people;
>
>
>
>
>
>
>
>
>
>
>
> $query= "SELECT * from $table_name WHERE $filter LIKE
> '%$search_string%'";
>
>
> $area= $_POST['area'];
>
>
> if ($area=="a") {
> $query .=" AND area LIKE '%%'";
> }
> else {
> $query .=" AND area='$area'";
> }
>
>
>
> $result = mysql_query($query);
>
>
> $query .= " ORDER BY sname";
>
>
>
>
> $result = mysql_query($query) or die('Error, query failed');
> while ($row=mysql_fetch_array($result)) {
>
> $email_addresses[] = $row['email'];
>
>
> $count = count($email_addresses);
> $recipients = implode(', ', $email_addresses);
> //this counts the number of entries
>
> //echo $count;
> //echo $recipients;
> }
>
> if (isset($SUBMIT)) {
> if (empty($mail_to)){
> ?>
> <script>
> alert ('You have not entered the recipients email address')
> </script>
> <?
> }
> else {
> ?>
> <script>
> alert ('Your email has been sucessfully sent')
> </script>
> <?
> }
> }
> ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php