0
I am trying to send an email with several variables passed via post. I cannot send the content of the email with all variables. What would be the correct syntax? Below is the code:
$name = $_POST['nome'];
$zip = $_POST['cep'];
$adress = $_POST ['endereco'];
$number = $_POST['numero'];
$comp = $_POST['complemento'];
$neigh = $_POST['bairro'];
$city = $_POST['cidade'];
$state = $_POST['estado'];
$iemail = $_POST['email'];
$phone = $_POST['telefone'];
$product = $_POST['produto'];
$model = $_POST['modelo'];
$brand = $_POST['marca'];
$report = $_POST['laudo'];
$date = $_POST['data'];
require 'phpmailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.meudominio.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]';// SMTP username
$mail->Password = 'minhasenha'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->setFrom('[email protected]', 'Contato');
$mail->addAddress($iemail); // Add a recipient
$mail->addReplyTo('[email protected]', 'Contato');
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Sua Ordem de Serviço Grupo SAB';
$mail->Body = '
<table id="recibo">
<h1>Ordem de serviço</h1>
<p>Cliente:'.$name'</p>
<p>CEP:'.$zip'</p>
<p>Endereço:'.$adress'</p>
<p>Numero:'.$number'</p>
<p>Complemento:'.$comp'</p>
<p>Bairro:'.$neigh'</p>
<p>Cidade:'.$city'</p>
<p>Estado:'.$state'</p>
<p>Produto:'.$produtc'</p>
<p>Modelo:'.$model'</p>
<p>Marca:'.$brand'</p>
<p>Laudo:'.$report'</p>
</table>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
?>
When you say you can’t send with ALL variables, it means some work?
– Victor Eyer
No. All variables work correctly. However, at the moment of constructing the body of the email, in <Prev>$mail->Body = ''<code>I am trying to include all variables by closing the single quotes, concatenating the variable and opening the single quote and following this procedure until the end of the body. But then I can’t send the email and results in error
– Fábio Espíndola
Reverse. Use Quotes to open the string and single quotes for tags. Plus which error you get?
– Willian Coqueiro
You’re concatenating in the wrong way.
– geekcom
This error: Parse error: syntax error, Unexpected T_CONSTANT_ENCAPSED_STRING in /home/Storage/9/d0/82/brastempconsuleletr1/public_html/admin/enviarods.php on line 83
– Fábio Espíndola