简体   繁体   English

在 email 消息/正文中打印 PHP 文件的内容

[英]Print contents of PHP file in email message / body

I want to write a PHP page to run on a cron job to email out the contents of a PHP page.我想写一个 PHP 页面以在 cron 作业上运行到 email 输出 PHP 页面的内容。

When trying this, I get the scripts included in the body of the email, not just the echoed out elements.尝试此操作时,我得到了包含在 email 正文中的脚本,而不仅仅是回显的元素。

Here is the script I'm using below currently to try and include kpi.php in the email.这是我目前在下面使用的脚本,用于尝试将 kpi.php 包含在 email 中。

Any thoughts on how I can achieve this?关于如何实现这一目标的任何想法?

alternatively I'd be happy to grab a screenshot of the page.或者我很乐意获取页面的屏幕截图。

Thanks谢谢

 <?php $to = "email@domai.com"; $subject = "Daily Update"; $message = include('kpi.php'); // Always set content-type when sending HTML email $headers = "MIME-Version: 1.0". "\r\n"; $headers.= "Content-type:text/html;charset=UTF-8". "\r\n"; // More headers $headers.= 'From: <no-reply@email.com>'. "\r\n"; mail($to,$subject,$message,$headers); ?>

Just include it beforehand and echo the variables needed into the body of the email只需预先包含它并将所需的变量回显到 email 的主体中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM