다른 내용으로 여러 개의 전자 메일을 보내려고합니다. 사용자는 확인란을 선택하고 버튼을 클릭하여 모든 전자 메일을 검사해야합니다.phpmailer에서 for 루프를 사용하여 여러 개의 전자 메일 보내기
그 때문에 데이터베이스의 콘텐츠 만 표시 할 수있는 표가 있습니다.
select nomeUser,email,nomeVoucher,categoria,preco,confirmacao,fileName,filePDF
from historico
Where confirmacao = 'a confirmar'
LIMIT $start, $per_page";
$stmt = $mybd->prepare($query);
$stmt->execute();
$stmt->bind_result($nomeUser,$email,$nomeVoucher,$categoria,$preco,$confirmacao,$file2,$filePDF);
while($stmt->fetch()){ ?>
<tbody>
<tr><td><?php echo $nomeUser ?></td>
<td><?php echo $email ?></td>
<td><?php echo $nomeVoucher ?></td>
<td><?php echo $categoria ?></td>
<td><?php echo $preco ?></td>
<td><?php echo $confirmacao ?></td>
<?php $current = file_get_contents($file2,$filePDF); ?>
<td style='display:none;'><?php echo $current ?></td>
<td style='display:none;'><?php echo $file2 ?></td>
<td><INPUT TYPE='checkbox' NAME='mail[]' VALUE='1'></td>
</tr>
</tbody>
<?php }$stmt->close();
코드를 보낼 수는있다 :
if(isset($_POST['enviar'])){
$mails = $_POST['mail'];
if(count($mails) > 0){
for($i=0;$i<count($mails);$i++){
$fromname[$i] = "Compra do Voucher";
$from[$i] = "[email protected]";
$subject[$i] = "Compra do Voucher";
$message = "O seu pagamento foi verificado com sucesso!" . "\r\n" .
"Por favor, verifica se o voucher pedido é o sucedido: " . "\r\n" .
"Categoria: $categoria[$i] \r\n" .
"Nome do Voucher: $nomeVoucher[$i] \r\n" .
"Preço: $preco[$i] € \r\n" .
"O seu voucher está disponível aqui $nomeVoucher[$i] \r\r\n" .
"Equipa do Voucher \r\n";
$new_array=array($email[$i]);
$newstring=implode(",",$new_array);
$mail = new PHPMailer();
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->Host = "smtp.sapo.pt";
$mail->Username = "[email protected]";
$mail->Password = "200886";
$mail->Port = 25;
$mail->Sender = "$from[$i]";
$mail->FromName = "$fromname[$i]";
$mail->Subject = "$subject[$i]";
$mail->Body = "$message";
$mail->CharSet="utf-8";
$mail->AddStringAttachment($current[$i],$file2[$i]);
$mail->AddAddress($newstring,$nomeUser[$i]);
if ($mail->send()){
return true;
}else
return $mail->ErrorInfo;
$mail->ClearAddresses();
$mail->ClearAttachments();
}
}
}
그것은 일 오류를 diplays : "잘못된 주소 : 당신은 하나 이상의받는 사람 이메일 주소를 제공해야합니다." 내가 뭘 잘못하고있어? 감사
documentation에서
첫 번째 예에서 구문 강조 표시를 정렬하십시오. 사람들이 이걸 이해할 수 있습니다 –