2012-04-18 75 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