I'm capturing the field:
$body = $result['mensagem_email'];
and sending via email by $mail
.
The problem is that I need to insert parameters in the html code that I look for in the registry of the bank and before sending change in the html code by [nome]
and [email]
with str_replace
.
It works, except that the email goes with the body of the duplicate message. Below the complete code: (the DEU CERTO PO ***) did not work ...
<?php
while($result = mysql_fetch_array($query)) {
$teste = "DEU CERTO PO***";
$id = $result[0];
$to = $result[1];
$status = $result[10];
$pixelLead = $result['id_lead'];// variavel que vai no link do pixel
$pixelCampanha = $result['id_campanha'];// variavel que vai no link do pixel
$subject = $result['assunto_email'];
//$body = str_replace('[teste]', $teste, $body );
$body = $result['mensagem_email'];
$body .= "<img src='http://www.tnnt.me/pixel.php?idLead=".$pixelLead."&idCampanha=".$pixelCampanha."' />";
$body .= str_replace('[teste]', $teste, $body );
// To send HTML mail, the Content-type header must be set
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "From: $nome_remetente <$email_remetente>\r\n";
$headers .= "Return-path: $nome_remetente <$email_remetente>";
mail($to,$subject,$body,$headers, "-r". $email_remetente);
$datahora=date('Y-m-d h:i:s'); //seta a data hora
mysql_query("UPDATE $tabela1 SET status_lead = 1 WHERE id_lead = $id");
mysql_query("INSERT INTO campanha_resultado (id_campanha, id_lead, data_envio) VALUES ($pixelCampanha,$pixelLead,NOW()) ");
printf("<font face=’tahoma’>$id ) mensagem para <b>$to</b> <font color=’#ff0000’><b>enviada com sucesso!</b></font></font>");
}
?>