dsfykqq3403 2013-01-21 06:22
浏览 24

为什么打印电子邮件中的html代码接收由PHP发送?

i am writing a code for Php mailer crone job. email is going and receiving but why i am receiving HTML code in email. instead of HTML template.

i also used proper email header and also test on other users email accounts. but same problem printing HTML code in email.

i also use <html><body><h2>Hello</h2></body></html> in message instead of template code. but same problem printing <html><body><h2>Hello</h2></body></html> in email receive.

Php code

 //database connection
        require_once("include/config.inc.php");
        require_once("include/functions.inc.php");

        //init function 
        mailerCrone();

        //defined functions
        function mailerCrone() {

            $site_admin  = 'myemail@gmail.com';
            $headers = "MIME-Version: 1.0" . "
";
            $headers .= "Content-type:text/html;charset=iso-8859-1" . "
";
            $headers = "From: " . $site_admin . "
";
            $headers .= "Reply-To: ". $site_admin . "
";

            $currentdate =  date('Y-m-d H:i:s');

            //get data to send mails 
            $getDataTomail = mysql_query("SELECT * FROM sendmails where status = 0 ORDER BY id ASC limit 0,10");

            while($resDataTomail = mysql_fetch_array($getDataTomail)) {

                $templateId = $resDataTomail['templ_id'];   
                $dataPreparedId = $resDataTomail['id'];     

                //get the template data
                $getTemplate = mysql_query("SELECT * FROM templates where id  = $templateId");
                $resTemplate = mysql_fetch_array($getTemplate);
                echo $msg = '<html><body>'.$resTemplate['templ_content'].'</body></html>';
                //mail($to, $subject, $message, $headers);
                $mailResponce = mail($resDataTomail['subs_email'], $resTemplate['templ_name'], $msg, $headers);

                if($mailResponce == '1') { 
                    //update status of selected data after send mail
                    $updateSendMailData = mysql_query("UPDATE sendmails SET status = '1' WHERE id = $dataPreparedId") or die(mysql_error());

                }
            }
        }
  • 写回答

2条回答 默认 最新

  • doulang9521 2013-01-21 06:48
    关注

    Change this:
    $headers = "From: " . $site_admin . " ";

    To this:
    $headers .= "From: " . $site_admin . " ";

    评论

报告相同问题?

悬赏问题

  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数