i am trying to send multiple mail using phpmailer. I have a problem. When i click send button, just zxc@gmail.com and abc@yahoo.com receives the message.
How to change it? I'm use Gmail SMTP send out.
There are 5 records in the database:
Here is my code:
How to change it? I'm use Gmail SMTP send out.
There are 5 records in the database:
Here is my code:
Code:
<?php $body=$_POST['message']; $subject=$_POST['sub']; //error_reporting(E_ALL); error_reporting(E_STRICT); date_default_timezone_set('America/Toronto'); require_once("class.phpmailer.php"); $con=mysql_connect("localhost","root","") or die("could not connect:".mysql_error()); mysql_select_db("bulkemail"); $qry=mysql_query("SELECT * FROM email_id", $con); if(!$qry) { die("Query Failed: ". mysql_error()); } while($row = mysql_fetch_array($qry)) { $id= $row['email']; $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->Host = "stmp.gmail.com"; // SMTP server $mail->SMTPDebug = 1; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = 'ssl'; $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server $mail->Port = 465; // set the SMTP port for the GMAIL server $mail->CharSet = "big5"; $mail->Username = "abc@gmail.com"; // GMAIL username $mail->Password = "......"; // GMAIL password $mail->SetFrom("abc@gmail.com", ''); // set reply id $mail->AddReplyTo("abc@gmail.com",""); $mail->Subject = ($subject); // subject $mail->AltBody = "Hey, check out this new post on www.techaltum.in"; // optional, comment out and test $mail->MsgHTML("$body"); // message $address = ($id); $mail->AddAddress($address); if(!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } } ?>
Comment