I need to send an email telling the user that your request is expired, I'm going to the bank and I'm looking for all the records in this condition, the problem is that the body of the email has to be the content of each line returned. In each e-mail you will have to go the data of the request of the user, the user can only receive the e-mail referring to his request, are data of entry, exit, time of permanence etc ...
I made a part of the code where it goes in the bank and sends the email to everyone, the problem is that the body of the email is always the same.
How do I get PHP to go to the bank and send these emails to a list and that the body of the message is the content of each line specific to each user?
Code that sends to everyone with a fixed body:
<?php
$select = "SELECT tb_movto_visitas.*, tb_cad_visitantes.nom_visitante, tb_cad_visitantes.qtd_visitas, tb_cad_motivos.des_motivo, dd_pessoais.nome, dd_pessoais.email FROM tb_movto_visitas
LEFT JOIN tb_cad_visitantes ON tb_movto_visitas.tb_cad_visitantes_cod_visitante = tb_cad_visitantes.cpf AND tb_movto_visitas.cod_visitado = tb_cad_visitantes.cpf_visitado
LEFT JOIN tb_cad_motivos ON tb_movto_visitas.tb_cad_motivos_cod_motivo = tb_cad_motivos.cod_motivo
LEFT JOIN dd_pessoais ON tb_movto_visitas.cod_visitado = dd_pessoais.cpf2
WHERE
dat_prev_saida < now() and dat_baixa = 0000-00-00 or
(dat_prorroga_1 < now() and dat_baixa = 0000-00-00 or dat_prorroga_2 < now() and dat_baixa = 0000-00-00)
ORDER BY tb_movto_visitas.'sol_visita' DESC";
$query = mysqli_query($conn , $select);
$row = mysqli_num_rows($query);
if ($row <> 0) {
while ($row_solicitacao = mysqli_fetch_assoc($query)) {
require_once '/../../lib/PHPMailer/PHPMailerAutoload.php';
$smtp_host = '130.100.10.24';
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = $smtp_host;
$mail->Port = 25;
$mail->From = '[email protected]';
$mail->FromName = 'Sistema de Visitas';
$array = explode(",",$row_solicitacao['email']);
$nb = count($array);
for ($i=0;$i<$nb;$i++) {
$mail->AddBCC($array[$i]);
}
$email_copia = "";
$assunto = 'AVISO DE VISITAS VENCIDAS';
$mensagem = "Prezado(a) Senhor(a) Diego Santos <br><br>";
$mensagem .= "De acordo com nosso cadastro de visitantes,<br>";
$mensagem .= "Para cumprimento do PAD2006, favor dirigir-se à t <br><br>";
$mensagem .= "Almeida <br><br>";
$mensagem .= "Visitantes: <br>";
$mensagem .= "Emissão: <br>";
$mensagem .= "Validade: <br>";
$mail->IsHTML(true);
$mail->CharSet = 'UTF-8';
$mail->Subject = $assunto;
$mail->Body = $mensagem;
$mail->AltBody = $mensagem;
$mail->Send();
}
}
?>