当前位置: 动力学知识库 > 问答 > 编程问答 >

Send PHPMailer HTML email with variables in PHP

问题描述:

Ok, i have this email that i wanna send by form with post method with PHPMailer. I wanna put the content of four variables inside the body of the message, but every time i recieve the email empty. The place of the variables is empty. What is wrong with my code?

 <?php

$nome = $_POST['nome'];

$telefone = $_POST['fone'];

$email = $_POST['email'];

$mensagem = $_POST['mensagem'];

require("class.phpmailer.php");

require('class.smtp.php');

$mail = new PHPMailer();

$mail->IsSMTP();

$mail->Host = 'smtp.studiobm.com.br';

//$mail->Host = "localhost";

$mail->SMTPAuth = true;

$mail->SMTPSecure = "tls";

$mail->Port = 587;

$mail->Username = "*******";

$mail->Password = "*******";

$mail->From = "[email protected]";

$mail->Sender = "[email protected]";

$mail->FromName = "Bruno Marques";

$mail->AddAddress('[email protected]', 'Bruno Marques');

$mail->Subject = "Bruno Marques Site";

$mail->Body = '<html><body style="margin:auto;width:599px;">

<img src="http://www.studiobrunomarques.com.br/site/wp-content/themes/bm/bannercontato.png" />

<table width="599" border="0" cellspacing="0" cellpadding="12" style="font-family:Arial;font-size:150%;background:#CCCCCC;">

<tr style="background:#e2e2e2;"><td>Nome:</td><td>'.$nome.'</td></tr>

<tr><td>E-mail:</td><td>'.$email.'</td></tr>

<tr style="background:#e2e2e2;"><td>Telefone:</td><td>'.$telefone.'</td></tr>

<tr><td>Mensagem:</td><td>'.$mensagem.'</td></tr>

</table>

</body></html>

';

$mail->IsHTML(true);

$enviado = $mail->Send();

$mail->ClearAllRecipients();

$mail->ClearAttachments();

if ($enviado) {

echo "E-mail enviado com sucesso!";

} else {

echo "Não foi possível enviar o e-mail.

";

echo "Informações do erro:

" . $mail->ErrorInfo;

}

?>

分享给朋友:
您可能感兴趣的文章:
随机阅读: