2012-09-02 96 views
3

目前我有发一些邮件,脚本结果的脚本有几个HTML表格:PHP的缓冲输出,CSS和邮件

$from = "prueba.com <[email protected]>"; 
$to = "[email protected]"; 
echo "<div>"; 

$contenido = ob_get_contents(); 
echo "</div>"; 
$cabeceras = "Content-type: text/html; charset=iso-8859-1 \r\n" 
      ."MIME-Version: 1.0 \r\n" 
      ."To: $cliente <$email> \r\n" 
      ."From: prueba <[email protected]> \r\n"; 

mail($to,$subject,$contenido,$cabeceras); 

ob_end_flush(); 

由于可能给CSS来的电子邮件?因为我尝试了几种方法,但都没有工作。

预先感谢您的合作

编辑:

这是我的代码http://www.mediafire.com/?bq9352xh6paji1d

+1

什么在你的$ contenido ???您需要指定css inline – jtheman

+0

$ contenido是将file_get_contents放入数组(具有glob函数的几个文件)并使用strip_tags的结果。结果是一些html表(文件的一个html表)。 – JuanFernandoz

+0

是的,但如果你想样式的HTML或者添加HEAD sectiion与CSS或ATT造型内嵌的风格=“” ... – jtheman

回答

3

也许你想是这样的:(使用ob_get_clean()

ob_start(); 
echo "<div>"; 
    // more html 
echo "</div>"; 
$contenido = ob_get_clean(); 

和失去最后ob_end_flush();

TEST:

$from = "prueba.com <[email protected]>"; 
$to = "[email protected]"; 
ob_start(); 
echo "<div>"; 
echo "<table border='1'><tr><td>TEST</td></tr></tr>"; 
echo "</div>"; 
$contenido = ob_get_clean(); 

$cabeceras = "Content-type: text/html; charset=iso-8859-1 \r\n" 
      ."MIME-Version: 1.0 \r\n" 
      ."To: $cliente <$email> \r\n" 
      ."From: prueba <[email protected]> \r\n"; 

mail($to,$subject,$contenido,$cabeceras); 
+0

的html之间的区别不起作用,但是谢谢。 – JuanFernandoz

+0

我刚刚做出的更新完美无缺。 –

+0

此脚本仅发送TEST表,但没有将脚本结果存储在缓冲区中。 – JuanFernandoz