PHP消息体看起来很分散

PHP消息体看起来很分散,php,html,css,Php,Html,Css,我被卡住了,不知道我做错了什么,我制作了一个简单的PHP邮件脚本,它可以正常发送,但我在localhost上创建的内容与我上传到服务器并运行测试时在收件箱中看到的内容不同。注意:在嵌入电子邮件脚本之前,我创建了原始表单,这是我在运行测试时在电子邮件收件箱中看到的内容。请问我做错了什么 $emailTo = $receiver; $emailFrom = $sender; $emailSubject = "Receipt from Zuwi int'l company Ltd [$

我被卡住了,不知道我做错了什么,我制作了一个简单的PHP邮件脚本,它可以正常发送,但我在localhost上创建的内容与我上传到服务器并运行测试时在收件箱中看到的内容不同。注意:在嵌入电子邮件脚本之前,我创建了原始表单,这是我在运行测试时在电子邮件收件箱中看到的内容。请问我做错了什么

     $emailTo = $receiver;  
$emailFrom = $sender;

$emailSubject = "Receipt from Zuwi int'l company Ltd [$r_reference]";

if($data['success'] == true){


$message = '<html><body>'; //I CREATED THIS MESSAGE BODY IN HTML, WORKS WELL BUT MALFUNCTIONING ON EMAIL
$message .= '<div style="width:100%;margin-top:7%;"><div align="center"><h1 style="font-size:1.3em!important;margin-bottom:15px!important;"><img src="https://www.ogafriday.com/images/zuwii.jpg" alt="Password Change" style="height:40px;width:40px;" /></h1><small style="font-size: 12px;     color: #555555;  line-height: 14px; font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;">If you have any issues with this payment, kindly reply to this email or send an email to <br/><a href="mailto:store@ogafriday.com" target="_blank" style="color:#50a1f7;">store@ogafriday</a></small><h1>';
$message .= '<div style="width:510px;border:0.5px solid #ededed;margin-top:25px;height:510px;"><div style="height:180px;  background: #d14836;"><div align="center" style="position:absolute;width:40%;margin-top:50px;"><p style="    margin: 0 auto;     max-width: 300px;     font-size: 18px;  color:#fff;   line-height: 18px;     text-align: center;       font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;">Zuwi int"l company Ltd received an outstanding unpaid invoice for</p><br/><h1 style="  margin: 0 auto;     max-width: 300px;     font-size: 36px;  color:#fff;   line-height: 18px;     text-align: center;  font-weight:bold;     font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;">NGN 12,000.00</h1></div></div><p style="word-wrap: break-word!important;margin-bottom:-8px!important;font-size:14px;font-family:Verdana;"><b style="color:#555555;">Transaction Details</b> </p><br/>';
$message .= '<table rules="all" style="border-color: #dbdbdb;" cellpadding="10">';
$message .='<tr><td> </td></tr><br/><div style="margin-top:10px;position:absolute;margin-left:2%;margin-right:2%;border-bottom:0.5px solid #ededed;width:33%;padding-bottom:32px;"><div style="margin-left:0px;position:absolute;color:#555555;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;"> Reference </div> <div style="margin-left:65%;position:absolute;width:50%;color:#555555;font-weight:bold;position:absolute;width:50%;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;">'.$r_reference.'</div></div><br/><div style="margin-top:45px;position:absolute;margin-left:2%;margin-right:2%;border-bottom:0.5px solid #ededed;width:33%;padding-bottom:35px;"><div style="margin-left:0px;position:absolute;color:#555555;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;"> Date </div> <div style="margin-left:65%;position:absolute;width:50%;color:#555555;font-weight:bold;position:absolute;width:50%;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;"> '.$r_date.' </div></div><br/><div style="margin-top:85px;position:absolute;margin-left:2%;margin-right:2%;border-bottom:0.5px solid #ededed;width:33%;padding-bottom:40px;"><div style="margin-left:0px;position:absolute;color:#555555;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;"> Method </div> <div style="margin-left:62%;color:#555555;font-weight:bold;position:absolute;width:50%;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;">Pay on delivery </div></div>';
$message .= '<div style="margin-top:33%;"><p style="font-size: 16px;     color: #555555;  line-height: 14px; font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;">Zuwi intl company Ltd</p> <p style="margin-top:-10px;"><a href="mailto:store@ogafriday.com" target="_blank" style="color:#50a1f7;font-size:14px;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;">store@ogafriday</a></p></div></div></div></div>';
$message .= "</table>";
$message .= "</body></html>";


$headers = "MIME-Version: 1.0" . "\r\n"; 
$headers .= "Content-type:text/html; charset=utf-8" . "\r\n"; 
$headers .= "From: <$emailFrom>" . "\r\n";
mail($emailTo, $emailSubject, $message, $headers);

$data['success'] = true;

json_encode($data);
$emailTo=$receiver;
$emailFrom=$sender;
$emailSubject=“Zuwi国际有限公司的收据[$r_参考]”;
如果($data['success']==true){
$message='';//我用HTML创建了此邮件正文,运行良好,但在电子邮件中出现故障
$message.=“如果您对此付款有任何问题,请回复此电子邮件或发送电子邮件至
”; $message.='

Zuwi int“l有限公司收到了一张未付的发票,金额为12000.00 NGN”

交易详情; $message.=''; $message.='
参考'.$r_参考'.
日期'.$r_日期'.
方法交货付款'; $message.='

Zuwi国际有限公司; $message.=“”; $message.=“”; $headers=“MIME版本:1.0”。\r\n”; $headers.=“内容类型:text/html;字符集=utf-8”。\r\n”; $headers.=“From:”\r\n”; 邮件($emailTo、$emailSubject、$message、$headers); $data['success']=true; json_编码($data);


将代码转换为表格结构,然后它就会工作。我只需将代码更改为表格格式,现在您可以添加任何样式

浏览器视图

记住 为获得最佳视图,请使用电子邮件模板的表结构

$message = '<html><body>'; //I CREATED THIS MESSAGE BODY IN HTML, WORKS WELL BUT MALFUNCTIONING ON EMAIL
$message .= '<table style="width:100%;margin-top:7%;"><tr><td><div align="center"><h1 style="font-size:1.3em!important;margin-bottom:15px!important;"><img src="https://www.ogafriday.com/images/zuwii.jpg" alt="Password Change" style="height:40px;width:40px;" /></h1><small style="font-size: 12px;     color: #555555;  line-height: 14px; font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;">If you have any issues with this payment, kindly reply to this email or send an email to <br/><a href="mailto:store@ogafriday.com" target="_blank" style="color:#50a1f7;">store@ogafriday</a></small><h1>';
$message .= '<div style="width:510px;border:0.5px solid #ededed;margin-top:25px;height:510px;"><div style="height:180px;  background: #d14836;"><br><p style=" margin: 0 auto; max-width: 300px;     font-size: 18px;  color:#fff;   line-height: 18px;     text-align: center; font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;">Zuwi int"l company Ltd received an outstanding unpaid invoice for</p><br/><h1 style="  margin: 0 auto;     max-width: 300px;     font-size: 36px;  color:#fff;   line-height: 18px;     text-align: center;  font-weight:bold;     font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif;">NGN 12,000.00</h1></div><p style="word-wrap: break-word!important;margin-bottom:-8px!important;font-size:14px;font-family:Verdana;"><b style="color:#555555;">Transaction Details</b> </p><br/>';
$message .= '<table width="90%" style="margin:0px auto;" border="0" cellpadding="10" cellspacing="0">
    <tr>
        <td style="border-bottom:1px solid #ddd;">Reference</td>
        <td style="border-bottom:1px solid #ddd;" align="right">You text</td>
    </tr>
    <tr>
        <td style="border-bottom:1px solid #ddd;">Date</td>
        <td style="border-bottom:1px solid #ddd;" align="right">You text</td>
    </tr>
    <tr>
        <td style="border-bottom:1px solid #ddd;">Method</td>
        <td style="border-bottom:1px solid #ddd;" align="right">You text</td>
    </tr>
    <tr>
        <td align="center" colspan="2"><br><p>Zuwi intl company Ltd</p><a href="mailto:store@ogafriday">store@ogafriday</a></td>
    </tr>
    <tr>
        <td align="center" colspan="2"></td>
    </tr>
</table>';
$message .= "</td></tr></table></body></html>";
$message='';//我用HTML创建了此邮件正文,运行良好,但在电子邮件中出现故障
$message.=“如果您对此付款有任何问题,请回复此电子邮件或发送电子邮件至
”; $message.='

Zuwi int“l有限公司收到了一张未付的发票,金额为12000.00 NGN”

交易详情; $message.=' 参考文献 你发短信 日期 你发短信 方法 你发短信
祖维国际有限公司

'; $message.=“”;
感觉你的样式不好。你考虑过使用样式表吗?@progrAmmar,从我发现的情况来看,你不能在电子邮件中使用外部样式,它是内联的。内联不利于编码。或者第三方样式?会研究一下@christianmark你应该为具有内联样式的电子邮件布局创建一个表结构。看看这个@S哈沙