我正在尝试使用 phpmailer 发送批量电子邮件当我单击发送按钮时,我的数据库中有超过 10 个电子邮件 ID,然后第一封电子邮件将发送给一个人,发送的第二封电子邮件将发送给同一个人加上另一个人,第三个将去那两个加一,以此类推。这是我的编码,请帮助我
<?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");
//include("class.smtp.php");
$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
// 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->Subject = ($subject); // subject
$mail->MsgHTML("$body"); // message
$mail->AddAddress($address, "abc");
$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"];
$address = ($id);
$mail->AddBcc($id);
$mail->send();
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
}
else {
echo "Message sent!";
}
}
?>