我正在尝试在.phtml
内部回声发送电子邮件。
但是,我对报价遇到麻烦。图像未显示。
<?php echo '
Plataforma <a href="http://xxxx.com/">http://xxxx.com/</a>
<br>
<div style="width:220px; height:30px; background-color:black; background-repeat: no-repeat; background-image:url("http://www.inova-ria.pt/images/UebeImg/Thumb/Img_153_363_T.jpg")"></div>
'
?>
IDE将此代码验证为正确,但是在发送的电子邮件中未显示图像。
<?php echo '
Plataforma <a $href="http://xxxx.com/">http://xxxx.com/</a>
<br>
<div $style="width:220px; height:30px; background-color:black; background-repeat: no-repeat; background-image:url("http://www.inova-ria.pt/images/UebeImg/Thumb/Img_153_363_T.jpg")"></div>
'
?>
样式属性的价值是由双引号包围的,因此内部的任何双配额都必须逃脱。
您需要更改此信息:
background-image:url("http://www.inova-ria.pt/images/UebeImg/Thumb/Img_153_363_T.jpg")
to:
background-image:url('http://www.inova-ria.pt/images/UebeImg/Thumb/Img_153_363_T.jpg')
双引号正在切断您在错误的位置的DOM,导致它错误地阅读。
您的CSS无效。更改此行:
background-image:url("http://www.inova-ria.pt/images/UebeImg/Thumb/Img_153_363_T.jpg")
这样阅读:
background-image:url('http://www.inova-ria.pt/images/UebeImg/Thumb/Img_153_363_T.jpg')
由于它在样式="属性中,因此"背景图像线中的符号"发出了样式属性的结尾,而不是图像的路径。
尝试使用单个逃脱的引号,例如图像的URL:
<?php echo '
Plataforma <a href="http://xxxx.com/">http://xxxx.com/</a>
<br>
<div style="width:220px; height:30px; background-color:black; background-repeat: no-repeat; background-image:url('http://www.inova-ria.pt/images/UebeImg/Thumb/Img_153_363_T.jpg')"></div>
'
?>
其他任何答案都没有解决问题(gmail,hotmail)。这将起作用
<?php echo '
Plataforma <a href="http://xxxx.com/">http://xxxx.com/</a>
<br>
<div style="width:220px; height:30px; background-color:black;">
<img src="http://www.inova-ria.pt/images/UebeImg/Thumb/Img_153_363_T.jpg">
</div>
'; ?>