How to send email with PHP with IF in the middle of the message?

Asked

Viewed 28 times

-2

I have a code that sends e-mail through php In the middle of it I need to make the condition if, but I’m having syntax error, I’ll leave my code below

    $message .= "<br>";

$message .= "<p style=\"text-align: center;\"><br /><strong>TERMO DE TRANSFERENCIA DE RESPOSNSABILIDADE DE BENS PATRIMONIAIS</strong></p>
<p>&nbsp;</p>
<p style=\"text-align: justify;\"><br />Eu ".$responsavel_saida." , Loja:".$nroempresa.", Setor: ".$setor.", at&eacute; a presente data respons&aacute;vel pelos bens constantes no relat&oacute;rio em anexo, DECLARO esta transferindo a responsabilidade sobre os mesmo para a Loja: ".$nroempresa_destino.", Setor: ".$setor_destino.", que passara a ter a inteira responsabilidade pela guarda, uso, controle e conserva&ccedil;&atilde;o dos mesmos, respondendo tamb&eacute;m pelas quantidades.</p>
<p>&nbsp;</p>
<p style=\"text-align: right;\"><strong>Loja:</strong> ".$nroempresa.", <strong>Data:</strong>".$dtasaida."</p>
<p>&nbsp;</p>
<p><img alt=Embedded Image src='$signature' width=\"200px\" height=\"100px\"/></p>
<p>&nbsp;</p>
<p><br /><br /><strong>Resp.pelo setor Sa&iacute;da: ".$responsavel_saida."</strong>&nbsp;</p>
<p><table border='1'>
<tr>
<td>N. Plaqueta </td><td>Descricao </td><td>Empresa </td><td>Setor</td></tr><tr>

if ($plaqueta1 == TRUE) {




<td>".$plaqueta1." </td><td> ".$descdetalhada." </td><td> ".$nroempresa." </td><td> ".$setor."</td></tr>

}
if ($plaqueta2 == TRUE) {




<td>".$plaqueta2." </td><td> ".$descdetalhada." </td><td> ".$nroempresa." </td><td> ".$setor."</td></tr>

}

happens that ifs appear in the body of the message, gets ugly

1 answer

0


See if that’s what you need:

$message .= "<br>";

$message .= "<p style=\"text-align: center;\"><br /><strong>TERMO DE TRANSFERENCIA DE RESPOSNSABILIDADE DE BENS PATRIMONIAIS</strong></p>
<p>&nbsp;</p>
<p style=\"text-align: justify;\"><br />Eu ".$responsavel_saida." , Loja:".$nroempresa.", Setor: ".$setor.", at&eacute; a presente data respons&aacute;vel pelos bens constantes no relat&oacute;rio em anexo, DECLARO esta transferindo a responsabilidade sobre os mesmo para a Loja: ".$nroempresa_destino.", Setor: ".$setor_destino.", que passara a ter a inteira responsabilidade pela guarda, uso, controle e conserva&ccedil;&atilde;o dos mesmos, respondendo tamb&eacute;m pelas quantidades.</p>
<p>&nbsp;</p>
<p style=\"text-align: right;\"><strong>Loja:</strong> ".$nroempresa.", <strong>Data:</strong>".$dtasaida."</p>
<p>&nbsp;</p>
<p><img alt=Embedded Image src='$signature' width=\"200px\" height=\"100px\"/></p>
<p>&nbsp;</p>
<p><br /><br /><strong>Resp.pelo setor Sa&iacute;da: ".$responsavel_saida."</strong>&nbsp;</p>
<p><table border='1'>
<tr>
<td>N. Plaqueta </td><td>Descricao </td><td>Empresa </td><td>Setor</td></tr><tr>";

if ($plaqueta1 == TRUE) {

    $message .= "<td>".$plaqueta1." </td><td> ".$descdetalhada." </td><td> ".$nroempresa." </td><td> ".$setor."</td></tr>";

}
if ($plaqueta2 == TRUE) {

    $message .= "<td>".$plaqueta2." </td><td> ".$descdetalhada." </td><td> ".$nroempresa." </td><td> ".$setor."</td></tr>";

}

Recommended reading: PHP: String Operators

Related: PHP: Control Structures - if

  • 1

    worked, thanks

  • The community recommends accepting the answer as a solution, rather than commenting "it worked, thank you"... Hugging! ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.