我有一个php页面,它是一个动态生成的票证页面,我添加了一个按钮来打印票证内容。这是一个例子
<html>
<body>
<div id="ticket-div">
<table><?php here goes the contents of ticket ?></table>
</div>
<button>Print this ticket</button>
<button>Email Ticket</button>
</body>
</html>
我想知道如何只使用我使用的邮件功能中的div内容。
<?
if(($Content = file_get_contents("ticket.php")) === false) {
$Content = "";
}
$Headers = "MIME-Version: 1.0\n";
$Headers .= "Content-type: text/html; charset=iso-8859-1\n";
$Headers .= "From: ".$FromName." <".$FromEmail.">\n";
$Headers .= "Reply-To: ".$ReplyTo."\n";
$Headers .= "X-Sender: <".$FromEmail.">\n";
$Headers .= "X-Mailer: PHP\n";
$Headers .= "X-Priority: 1\n";
$Headers .= "Return-Path: <".$FromEmail.">\n";
if(mail($ToEmail, $Subject, $Content, $Headers) == false) {
//Error
}
&GT;
我想要的是,只需在电子邮件中附上div“ticket-div”的内容,以便客户可以从他的邮件中下载。
提前致谢
答案 0 :(得分:1)
您需要为此目的使用javascript并指定headers.use下面的代码
<?php
if($_GET['email']){
$to = "xyz@xyz.com"; // Write the email here
$from = 'info@phpgang.com'; // Write your email here
$headers = "From: " . strip_tags($from) . "\r\n";
$headers .= "Reply-To: ". strip_tags($from) . "\r\n";
$headers .= "CC: info@sitename.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = "
<div id='ticket-div'>
<table>here is the content of the ticket</table>
</div>
";
mail($to, $subject, $message, $headers);
}
echo $message = "
<div id='ticket-div'>
<table>here is the content of the ticket</table>
</div>
";
?>
<button onclick='window.print();'>Print this ticket</button>
<form action='url to this file.php' method='POST'>
<input type='submit' name='email' id='button'>Email Ticket</button>
</form>
上面的代码可能需要一些时间,但它肯定会传递您的邮件。
我制作了一个你想要的脚本,从这个网址wpbrisk.com/download/email/email/email.zip
下载。或者您可以通过访问此URL
http://wpbrisk.com/download/email/email/index.php?email_addr=YOUR_EMAIL_ADDRESS_HERE
我整个前夕都在为这个剧本工作,并将在我的网站http://hangupin.com上写一篇文章。一定要读它 希望这可以帮助你