2012-04-18 59 views
1

我想將頁面內容發送至電子郵箱。 我寫了發送頁面內容至郵箱

if($_GET['send_mail'] == 1){ 
$message = file_get_contents('send_daily_bespoke_call_status.php'); 
echo "sendmail" . $message; 
mail('[email protected]', 'Report for Bespoke Users', $message);  
} 

但是頁面並沒有永久加載。 如何將頁面內容發送至電子郵件。 我的頁面內容有幾個陣列,所以我不能包括< <等

+0

你需要在php.ini中指定正確的smtp服務器 – 2012-04-18 14:42:44

回答

2

如何使用對象緩存:

if($_GET['send_mail'] == 1){ 
    ob_start(); 
    include 'send_daily_bespoke_call_status.php'; 
    $output_buffer = ob_get_contents(); 
    ob_end_clean(); 
    mail('[email protected]', 'Report for Bespoke Users', $output_buffer); 
} 

另外,代替mail()你可以使用PEAR的SMTP郵件包:http://pear.php.net/package/Mail/

+1

這對我有用。 $ body = file_get_contents('send_daily_bespoke_call_status.php'); $ body = eregi_replace(「[\]」,'',$ body); ('[email protected]','定製用戶報告',$ body); – 2013-04-06 19:23:39