dongshi3061 2016-02-19 06:16
浏览 139

发送从PHPmailer中的sql查询收集的动态变量

I am trying to use PHP Mailer to send dynamic emails. the issue i face is that the variable values are not going in the email, infact nothing is being sent in the email from the p tags where the variable is stored. the email however goes fine.Not sure what i am missing , Please see the code below :-

<html>
    <head>
      <style>

            .email-background {
            background: #eee;
            padding:10px;

            }
            .email-container {
             max-width:800px;
              background: #fff;
             margin:0 auto;
             padding:20px;
             color: #b3d1ff;
             }
             .pre-header {
        max-width: 800px;
        background: #66a3ff none repeat scroll 0% 0%;
        text-align: center;
        margin: 0px auto;
        padding: 20px;
        font-size: 20px;
        font-weight: 800;
        font-family: montserrat;
        color: #fff;


             }
             img {
             max-width:100%;
             }
             hr { 
            display: block;
            margin-top: 0.5em;
            margin-bottom: 0.5em;
            margin-left: auto;
            margin-right: auto;
            border-style: inset;
            border: 2px solid #eee;
        } 
      </style> 
    </head>
    <body>
    <div class="email-background">
      <div class="pre-header">
      Your Weekly.......
      </div>
      <div class="email-container">
          <p>Dear %$firstname%,</p>
          <h1>Test Email</h1>


         <tr>
           <td>
           test1 test2
           </td>
           <td>
           firstname
           Lastname

           <hr>
           </td>
         </tr>
       <div class="email-footer">

       </div>


       </div>



       </div>     

    </body>
</html>

    $mail = new PHPMailer(true);



$mail->IsMail();


$mail->setFrom('test.com');

$mail->addAddress($row3["email"]);               // Name is optional
$mail->addReplyTo('info@example.com', 'Information');

$mail->isHTML(true);                     // Set email format to HTML

$mail->Subject = 'test email!!!';
$body= file_get_contents ('/Autoaction/phpmailer.html');

$body = str_replace('%$firstname%',$firstname,$body);   
$body = preg_replace('/\\\\/','', $body);        
$mail->msgHTML($body);
//$mail->Send();                    



if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
    echo 'Message has been sent';
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
    • ¥170 如图所示配置eNSP
    • ¥20 docker里部署springboot项目,访问不到扬声器
    • ¥15 netty整合springboot之后自动重连失效
    • ¥15 悬赏!微信开发者工具报错,求帮改
    • ¥20 wireshark抓不到vlan
    • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
    • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
    • ¥15 stata安慰剂检验作图但是真实值不出现在图上
    • ¥15 c程序不知道为什么得不到结果