【发布时间】:2014-01-21 04:23:44
【问题描述】:
我的页面结构如下:
<?php
session_start();
ob_start();
?>
HTML HEADER
links to stylesheets global.css and mail.css
<?php
function email(){
/* using the stylesheets global.css and mail.css */
$text = '<div class="test">
<p id="par">...
<span id="write" class="text">...</span>
</p>
</div>';
return $text;
}
?>
/* some text and html stuff */
<?php
if(isset(...)){
/* php form validation */
/* after validating I send an email to the user where I call
the function email() which use the stylesheets. */
$mail_text = 'Dear .....';
$mail_text .= email();
$mail_headers = "From: test@test.com\r\n".
'X-Mailer: PHP/' . phpversion().
'MIME-Version: 1.0' . "\r\n".
'Content-type: text/html; charset=utf-8' . "\r\n";
if(mail(..., ..., $mail_text, $mail_headers)){
header('location: newlocation.php');
}
?>
/* HTML FORMS and text and .... */
<?php
ob_end_flush();
?>
电子邮件与来自 email() 函数的文本一起发送,但没有格式化导致 CSS 仅在页面底部的 ob_end_flush() 之后“打印出来”。
我该如何解决? email()里面有很多类和样式,所以每次都写<div style="...">之类的不是很好的解决办法。
【问题讨论】: