phpmailer를 사용하여 데이터베이스에있는 각 전자 메일 주소로 전자 메일을 보내려고하지만 고유 한 전자 메일로 사용하려고합니다. 웬일인지, 그것은 중복되는 전자 메일을 보내고, 내 쿼리가 행을 반환 할 때만큼 많은 복사본을 전송합니다. 따라서 내 쿼리가 5 개의 행을 반환하면 각받는 사람에게 5 개의 전자 메일이 전송됩니다 (총 전자 메일은 25 개입니다). 이메일 내용이 개인화되어 있기 때문에 여러 수신자에게 동일한 이메일을 사용할 수 없습니다.mysql 결과가있는 phpmailer
코드에 어떤 오류가 있습니까? 도와주세요 ...
여기 내 코드입니다 :
$customers_query = "SELECT customer_name, customer_email, customer_id FROM customers";
$customers = mysql_query($customers_query);
if (!$customers) {
$message = 'Error notice: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
require_once('class.phpmailer.php');
// create an instance
while ($row = mysql_fetch_array($customers)) {
$email = $row['customer_email'];
$name = $row['customers_name'];
$id = $row['customer_id'];
$mail = new PHPMailer();
// use sendmail for the mailer
$mail->IsSendmail();
$mail->SingleTo = true;
$mail->IsHTML(true);
$mail->From = "[email protected]";
$mail->FromName = "MyWebsite";
$mail->Subject = "Welcome to MyWebsite";
$mail->AddAddress($email);
$mail->Body = "Dear ".$name.", welcome to MyWebsite. Your ID is: ".$id.". Enjoy your stay.";
$mail->Send();
}
그래서, 여기에 무엇을 놓친 거지가? 왜 많은 이메일을 보냅니 까?
모든 이메일이 똑같은 사본을 보내고 있습니까? 아니면 각기 다른 이름과 ID를 가진 여러 개의 이메일을 보내고 있습니까? – mathius1
사이드 노트와 마찬가지로 : mysql 함수는 더 이상 사용되지 않습니다. mysqli 나 PDO를 더 안정적이고 안전하게 사용하십시오. –