我有一个 php 脚本,当用户回复帖子时应该向管理员发送一封电子邮件。这工作正常,但它同时发送 4 封邮件,并且对于相同记录的相同邮件,而不是使用 phpmailer 发送邮件来发送 1 封邮件
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Host = 'smtp.hostinger.com';
$mail->Port = 587;
$mail->SMTPAuth = true;
$mail->Username = 'noreply@joint2purchase.com';
$mail->Password = 'manjunath123M';
$mail->setFrom('noreply@joint2purchase.com', 'admin joint2purchase');
$stmt = $db->query('SELECT USERNAME,EMAIL FROM MEMBERS LIMIT 100');
//for each email add a recipient
while($row3 = $stmt->fetch()){
$toname = $row3['USERNAME'];
$tomail = $row3['EMAIL'];
$mail->addAddress($tomail);
}
//build the rest email (html, attaches, etc)
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'created new thread';
$mail->Body = '<html>
<head>
<title>Admin Started with You : '.$name.' </title>
</head>
<body>
<h1>Thanks you for joining with us!</h1>
<table cellspacing="0" style="border: 2px solid #202020; height: 60%; width: 100%;">
<tr style="background-color:lightblue;">
<th>Joint2Purchase</th>
</tr>
<br/> <br/>
<tr style="background-color: white;">
<th>'.$toname.', started a new conversation with you at Joint2Purcahse. </th>
</tr>
<tr>
<th style="color:skyblue; font-size:30px; font-family:calibri; font-weight:boldder; border-bottom:1px solid skyblue;"> '.$name.'</th>
</tr>
<tr style="height:70px;">
<br/> <a href="joint2purchase.com/viewthread.php?id='.$example.'">View Conversation</a></th>
</tr>
</table>
</body>
</html>';
陪伴而非守候
繁花如伊
手掌心