通过php邮件发送电子邮件时,内联css不会在电子邮件中打印

时间:2017-06-20 12:18:36

标签: php html css email

大家好我想通过电子邮件发送电子邮件功能在php但是在发送电子邮件和回复邮件正文之前它显示我需要的东西但是这个机构发送的邮件是一些css无法正常工作。我已经附加了两个图像(screenshorts),一个是在发送电子邮件之前,另一个是在我发送电子邮件之后,你会理解正确的。

$body.= '<table border=1><tr><th>Branch</th>';
            for($i=0;$i<count($sections);$i++)
            {
                if($sections[$i]!="Task Admin")
                $body.="<th>".$sections[$i]."</th>";
            }
            $body.="</tr>";
            foreach($mainarrayparent as $keys => $value ) {
            $body.="<tr>";
                foreach($value as $keys1 => $getbranch ) { 
                    $getb = mysql_query("SELECT * from branch where id = '".$keys1."'");
                    $getbrow = mysql_fetch_assoc($getb);

                    $body.="<td>".$keys1." - ".$getbrow['name']."</td>";
                    foreach($getbranch as $keys3 => $getinner ) {
                            if($getinner==0){
                            $body.="<td style='background-color:#C6EFCE;'>".$getinner."</td>";
                            }else if($getinner!=0){
                            $body.="<td style='background-color:#FFC7CE;'>".$getinner."</td>";
                            }
                            else{
                                echo $keys3;

                            }
                    }   
                }
                $body.="</tr>";
            }
                $body.="</table>";
            //#C6EFCE
            echo $body;
            // die;

    //get overdue 


    $subject = "Acquisition Updates";
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
    $headers .= 'From: <intranet@daylewis.net>' . "\r\n"; 
    $result = mail('jignesh.prajapati@daylewisplc.co.uk',$subject,$body,$headers);

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

嗯,我可能知道这一个。我记得有些电子邮件程序存在长文本问题。放置返回并切断可能导致问题的html。在某些循环的末尾添加一个返回或PHP_EOL可能有所帮助。

 foreach ($getbranch as $keys3 => $getinner) {
    if ($getinner == 0) {
        $body .= "<td style='background-color:#C6EFCE;'>" . $getinner . "</td>" . PHP_EOL;
    } else if ($getinner != 0) {
        $body .= "<td style='background-color:#FFC7CE;'>" . $getinner . "</td>" . PHP_EOL;
    } else {
        echo $keys3;

    }
}