-1
I am creating an email resend, I need it to work as follows, I want you to check the table and check all emails, if it is less than 30 days forward the email. I have this code below where before it was working, but the first email longer than 30 days that is found sends the email to him and the others does not send kkk. Could someone help me? I thank you in advance.
<?php
#dados para conexão com banco de dados
$strcon = mysqli_connect('localhost','root','','integracao') or die('Erro ao conectar ao banco de dados');
$search = mysqli_query($strcon,"SELECT * FROM tb_emprestimo WHERE DATA >= '(date_sub(curdate(), interval 30 day))'");
$linha =mysqli_fetch_array($search);
$emailDestino = $linha["EMAIL"];
$destinatario = $linha["NOME_PESSOA"];
if(@mysqli_num_rows($search) > 0){
// Caminho da biblioteca PHPMailer
require 'phpMailer/class.phpmailer.php';
// Instância do objeto PHPMailer
$mail = new PHPMailer;
// Configura para envio de e-mails usando SMTP
$mail->isSMTP();
// Servidor SMTP
$mail->Host = 'smtp.gmail.com';
// Usar autenticação SMTP
$mail->SMTPAuth = true;
// Usuário da conta
$mail->Username = '********@gmail.com';
// Senha da conta
$mail->Password = '********';
// Tipo de encriptação que será usado na conexão SMTP
$mail->SMTPSecure = 'ssl';
// Porta do servidor SMTP
$mail->Port = 465;
// Informa se vamos enviar mensagens usando HTML
$mail->IsHTML(true);
// Email do Remetente
$mail->From = '*********@gmail.com';
// Nome do Remetente
$mail->FromName = 'ZINA PORTO';
// Endereço do e-mail do destinatário
$mail->addAddress($emailDestino);
// Assunto do e-mail
$mail->Subject = 'Assunto';
// Mensagem que vai no corpo do e-mail
$mail->Body = '<h2>Olá, '.$destinatario.'</h2>
<p> MENSAGEM PARA DESTINATARIO</p>';
}
?>
In the title you say "after 30 days" and in the text "if it is less than 30 days send the email"... and in the code you use the operator
>=
.... In the code will pick up the records with 30 days or more. Got confused to know the objective due to the contradictions of information.– Sam
I meant if the date in the bank is shorter than today’s date. Ex: You are in the bank 01/03/2019, this is smaller than today 28/04/2019, consequently has more than 30 days. So you have to send the email. Am I right? Got it?
– Natanael Alves