问题描述
我想做邮件体。我已经尝试下面的方法来风格邮件主体。但所有人都无法工作
I want to style mail body. I have tried the below methods to style mail body. But all of them didn't work
1)使用外部样式表
style.css
1) Used external style sheet style.css
td{padding:10px;}
mail.php
<link rel="stylesheet" href="style.css"></link><table><td>....</td></table>
2)定义的内部样式表:
2) Defined Internal Style Sheet:
mail.php
<style type="text/css">
td{
padding-bottom:8px;
}
</style>
<table><td>....</td></table>
我知道,内联样式通过执行< td style = -bottom:8px'>
,但我有很多表,做内联样式不是一个好主意,有任何工作,所以不需要为每个元素定义样式
I know, Inline style works by doing <td style='padding-bottom:8px'>
, But i have got many tables, doing the inline style is not a good idea, Is there any work around so that no need to define style for each element
推荐答案
对于电子邮件,通常最安全的赌注是表和内联样式(一切你不应该在网页设计)。 >
for email, usually the safest bet is tables and inline styles (Everything you shouldn't be doing in web design).
$mailBody = '<html><body>';
$mailBody .='<table width="100%"><tr>';
$mailBody .='<td style="padding:10px"></td>';
$mailBody .='<td style="padding:10px"></td>';
$mailBody .='<td style="padding:10px"></td>';
$mailBody .='</tr></table>';
$mailBody .='</body></html>';
很遗憾,内部和外部样式表并不总是在不同的电子邮件客户端之间工作。
Sadly internal and external style sheets don't always work across different email clients.
这篇关于如何在PHP中设置电子邮件正文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!