PHP 邮件整个页面

发布于 2024-10-20 02:16:10 字数 935 浏览 1 评论 0原文

我有一个页面确定变量 ISSET,然后按照指令执行操作。例如,如果 isset 包含“print”,它会通过“包含模板路径”加载文件,并在底部回显打印窗口的代码。

例如。

if (isset($_GET['quoteprint'])) {
include(TEMPLATEPATH . '/bookings/booking-quote.php');
echo'<script type="text/javascript">window.print()</script>';
}

现在我希望存在类似的功能,但这次将该页面的内容通过电子邮件发送给用户。我厌倦了这个,但它不起作用。我认为内容需要转换,但我不知道从哪里开始。

else if (isset($_GET['quoteemail'])) {
    $emailer = include(TEMPLATEPATH . '/bookings/booking-quote.php');
    $to = $current_user->user_email;
  $subject = "Your Quote - Dive The Gap" ;
  $message = $emailer;
  $headers = "From: Dive The Gap Bookings <[email protected]>" . "\r\n" .
             "Content-type: text/html" . "\r\n";

  mail($to, $subject, $message, $headers);
}

有什么想法吗?

奇妙

I have a page that determines the variable ISSET and then acts on instructions. For example if the isset contains 'print' it loads a file via Include Template Path and echos a code on the bottom that prints the window.

eg.

if (isset($_GET['quoteprint'])) {
include(TEMPLATEPATH . '/bookings/booking-quote.php');
echo'<script type="text/javascript">window.print()</script>';
}

Now I would like a similar function to exist but this time to email the contents of that page to the user. I tired this but it does not work. I think the content needs to be converted but I don't know where to start.

else if (isset($_GET['quoteemail'])) {
    $emailer = include(TEMPLATEPATH . '/bookings/booking-quote.php');
    $to = $current_user->user_email;
  $subject = "Your Quote - Dive The Gap" ;
  $message = $emailer;
  $headers = "From: Dive The Gap Bookings <[email protected]>" . "\r\n" .
             "Content-type: text/html" . "\r\n";

  mail($to, $subject, $message, $headers);
}

Any ideas?

Marvellous

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

仅一夜美梦 2024-10-27 02:16:10

include 函数不会返回您所包含的脚本的输出或内容。
请参阅http://php.net/manual/en/function.include.php 了解更多信息(示例 #4 可能对您感兴趣)。

您需要将页面的全部内容或您想要通过电子邮件发送的部分放入变量中。实现此目的的一种方法是使用 PHP 的输出缓冲。关于输出缓冲如何工作的一个很好的解释可以在这里找到: http:// /www.codewalkers.com/c/a/Miscellaneous/PHP-Output-Buffering/

The include function does not return the output or content of the script you're including.
See http://php.net/manual/en/function.include.php for more info (example #4 might be interesting for you).

You need to get the entire content of the page, or the part(s) you'd like to e-mail, into a variable. One way of doing this is using PHP's output buffering. A good explanation of how output buffering works can be found here: http://www.codewalkers.com/c/a/Miscellaneous/PHP-Output-Buffering/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文