使用PHP中的变量发送PHPMailer HTML电子邮件

时间:2014-06-05 17:27:23

标签: php html email variables phpmailer

好的,我有这封电子邮件,我希望通过表格发送,使用PHPMailer的post方法。我想把四个变量的内容放在消息正文中,但每次我收到的电子邮件都是空的。变量的位置是空的。我的代码出了什么问题?

                            <?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 = "contato@studiobm.com.br"; 
            $mail->Sender = "contato@studiobm.com.br";
            $mail->FromName = "Bruno Marques"; 

            $mail->AddAddress('moafuhr@gmail.com', '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;
            }

            ?>

0 个答案:

没有答案