how are things going there?
I developed a php script to send an e-mail to a main user and some other copied users. When I test it putting the e-mail and names directly in the code like this: $mail->addAddress('email@provider.com','Any Name');
I receive the e-mail successfully, but when I get them from the mysql database like this: $mail->addAddress($r['userEmail',$r['userFullName']); $mail->addCC($r['userEmail2',$r['userFullName2']);
The script ran successfully, but the e-mail never arrives.
Did someone face something like that before and can help to solve my issue?
See all my code:
<?php
include '../dao/conn.php';
require_once('../inc/phpmailer/class.phpmailer.php');
$mail = new PHPMailer(true);
$mail->IsSMTP();
$mail->Host = 'smtp.domainname.com';
$mail->Port = 25;
$mail->SetFrom('no-reply@domainname.com');
$mail->IsHTML(true);
//pesquisa os projetos finalizados ha mais de 90 dias expecificado pelo envio manual
$sql1 = "SELECT p.PDC_NumControle ID
,p.PDC_Nome Projeto
,DATE_FORMAT(g.GRT_DataInicio,'%d/%m/%Y') DataTermino
,datediff(sysdate(), g.GRT_DataInicio) Dias
,l.`Position Name` NomePresidente
,l.`Position Email` EmailPresidente
,u.ManagerName NomeGerente
,u.ManagerEmail EmailGerente
,u.ArchtectName NomeArquiteto
,u.ArchtectEmail EmailArquiteto
FROM tabgarantiaprojeto g
INNER JOIN tabprojetos p ON g.GRT_NumContProjeto = p.PDC_NumControle
INNER JOIN tabpwdusuario u ON u.USU_NumControle = p.PDC_NumContUsuario
WHERE g.GRT_Status = 1 AND g.GRT_NumControle = $idGarantia AND datediff(sysdate(), g.GRT_DataInicio) >= 90;";
$res1 = mysqli_query($conn, $sql1);
$rowCount = mysqli_num_rows($res1);
if($rowCount > 0) {
$r = mysqli_fetch_assoc($res1);
//Lê os dados do projetos e envia e-mail para o presidente
$diasProj = $r["Dias"];
$projID = $r["ID"];
$NomeProjeto = $r["Projeto"];
$dataTermino = $r["DataTermino"];
$mail->AddAddress($r['EmailPresidente'], $r['NomePresidente']);
$mail->addCC($r['EmailArquiteto'], $r['NomeArquiteto']);
$mail->addCC($r['EmailGerente'], $r['NomeGerente']);
$mail->Subject = "Garantia de Obra - $NomeProjeto";
$mail->AltBody = "";
$mail->IsHTML(true);
$conteudo = 'Here is my html content';
$mail->Body = $conteudo;
$resp = $mail->send();
if ($resp) {
$res = 1;
$msg = "E-mail de aviso enviado com sucesso!";
} else {
$res = 0;
$msg = "Não foi possivel processar sua solicitação por causa do seguinte erro: " . $mail->ErrorInfo;
}
$mail->ClearAddresses();
$mail->ClearCCs();
$mail->ClearBCCs();
}
Any help will be appreciated.