RE: Phpmailer sending duplicate messages...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 	while($row = mysqli_fetch_assoc($result))
> 	{
>      extract($row);         
> 
> $mail->IsSMTP();
> $mail->Host = "host.com"; 
> $mail->From = "info@xxxxxxxx";
> 
> $mail->From = "info@xxxxxxxx";
> $mail->FromName = "Company";
> $mail->AddAddress("$email", "$Contact");
> 
> $mail->IsHTML(True);      
> $mail->Subject = "$Subject";
> $mail->Body = "$PR";
> $mail->WordWrap = 50;
> 
> 
> 
> if(!$mail->Send())
> {
>    echo 'Message was not sent.';
>    echo 'Mailer error: ' . $mail->ErrorInfo;
> }
> else
> {
>    echo 'Message has been sent.';
> }
> 
> }

I bet your while loop over the "extract" is causing you to have:
user1
user1, user2
user1, user2, user3,...

Instead of polluting your symbol table, can't you just use the email field?
$email = $row['theEmailField'];

I've used code like this back in the day (Notice how the array $arr was unset):
$recipients = "arr[]=user1@xxxxxxxxxxx&arr[]=user2@xxxxxxxxxxx&arr[]=user3@xxxxxxxxxxx";
parse_str($recipients);
for($i=0; $i<count($arr); $i++){
    mail("$arr[$i]", "$subject", "$message", "From: <$sender>\n". "Reply-To: <$sender>\n");
}
unset($arr);


_________________________________________________________________
Boo! Scare away worms, viruses and so much more! Try Windows Live OneCare!
http://onecare.live.com/standard/en-us/purchase/trial.aspx?s_cid=wl_hotmailnews

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux