PHP 邮件整个页面
我有一个页面确定变量 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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/