当我试图从与PHPmailer同时发送电子邮件时,有时会向每个接收者发送2份,有时发送3份同一电子邮件(如随机发送)。
这里是我的法典。 你们是否认为存在问题?
$list = $_POST[ list ];
$items = rtrim($_POST[ items ],",");
$query = "SELECT * FROM `mail` WHERE `ID` IN ($items)";
$result = mysql_query($query);
$from = "donotreply@mysite.net";
$fromname = "mysite";
$mail = new PHPMailer(true);
$mail->IsSendmail();
$mail->From = $from;
$mail->FromName = $fromname;
$mail->Subject = "Your subscription was confirmed";
while ($row = mysql_fetch_array ($result))
{
// HTML body
$body .= "<p>Hi ". $row[ name ] ." <br /><br />";
$body .= "Your subscription request to " . $l_name ." s list was confirmed.<br /><br />";
$body .= "Thank You !<br /><br />";
// Plain text body (for mail clients that cannot read HTML)
$text_body = "To view the message, please use an HTML compatible email viewer!";
$mail->Body = $body;
$mail->AltBody = $text_body;
$mail->AddAddress($row[ email ]);
$mail->Send();
$mail->ClearAddresses();
}
您是否认为应该把“mail->send();
从左边排出,从一个阵列取所有电子邮件?
或者,你是否认为是MySQL问题的问题?
Edit:我对数据库进行了检查,但对数据库没有任何问题,但我发现,(邮袋中有2个邮件)它通常发送第一份电子邮件,但第二次发送的是被篡改的单人变量,即发送了被篡改的单人变量。
FIX:hey,我做了,我刚刚添加了$ person = “”;
,现在它运作完美!