-1
Node code below sending an email to a particular recipient however need by the number of invoices all in the same, in the code below it creates an email for each invoice.
I commented on the code where I would like the foreach was added to work accordingly, but I can’t make it work due to syntax.
Summing up the foreach that already exists at the top of the code to do only in the data of table in the body of the e-mail that will be sent.
foreach ($class->ListaFaturas($cnpj) as $dados) {
$fatura = $dados->getFatura().'<br>';
$dtemissao = $dados->getDtEmissao().'<br>';
$dtvencimento = $dados->getDtVencimento().'<br>';
$valor = $dados->getVlSaldo().'<br>';
$mail->From = "[email protected]"; #Seu e-mail
$mail->FromName = "teste";
$mail->AddAddress($email,$nome);
$mail->IsHTML(true);
$mail->Subject = "Faturas em atraso";
#Assunto da mensagem
$mail->Body = "
<table>
<thead>
<tr>
<th>Número da Fatura</th>
<th>Data de Emissão</th>
<th>Data de Vencimento</th>
<th>Valor</th>
</tr>
</thead>
<tbody>
<tr>
<!-- Foreach aqui -->
<td>$fatura</td>
<td>$dtemissao</td>
<td>$dtvencimento</td>
<td>$valor</td>
</tr>
</tbody>
</table>
";
$mail->AltBody = "";
$enviado = $mail->Send();
$mail->ClearAllRecipients();
$mail->ClearAttachments();
}