我们有一个在线测试,一旦完成,我们可以通过电子邮件发送给用户。但是,数据没有作为PDF附加,它在电子邮件中显示为一堆随机字母/数字。
有关导致此问题的建议吗?它几个月前一直在努力。
以下是代码:
<?php
$i_get_sid = isset($_GET["sid"]) ? (int)$_GET["sid"] : $i_sid;
$i_get_pass = isset($_GET["a"]) ? $_GET["a"] : $_SESSION['r_pass'];
$i_get_pass = addslashes($i_get_pass);
$i_qry1 = db_qry("SELECT * FROM reports WHERE sid={$i_get_sid} AND ispurchased=1 AND isenabled=1 AND passhash='$i_get_pass'")
or die("Error: report-4, SQL request error #1 ".mysql_error());
if($i_qry1) {
if($i_rec1=mysql_fetch_array($i_qry1)) {
$i_fname = $i_rec1["fname"];
$i_lname = $i_rec1["lname"];
$i_email = $i_rec1["email"];
}
db_free_result($i_qry1);
}
if(!empty($i_email)) {
ob_start();
include('inc/pages/report-3.inc.php');
$data = ob_get_contents();
ob_end_clean();
$data = wordwrap(base64_encode($data), 72, "\n", true);
$i_boundary = '----------'.bin2hex(mhash(MHASH_MD5, time()));
$i_headers = "From: oursite.com <info@oursite.com>
X-Mailer: oursite.com PHP Mail (v1.0)
Reply-To: oursite.com <info@oursite.com>
X-Priority: 3 (Normal)
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary=\"$i_boundary\"";
$i_message = "--$i_boundary
Content-Type: text/plain;
charset=\"iso-8859-1\"
Content-Transfer-Encoding: 7bit
Dear ".$i_fname." ".$i_lname.",
Here is the report you asked for, attached as an Adobe Acrobat document.
If you do not already have one, an Adobe Acrobat reader can be downloaded
for free at http://www.adobe.com/.
----
Best regards,
OurSite Team
mailto:info@oursite.com
--$i_boundary
Content-Type: APPLICATION/PDF; name=\"report.pdf\"
Content-transfer-encoding: base64
Content-Disposition: attachment; filename=\"report.pdf\"
$data
{$i_boundary}--
";
@mail($i_email, 'Our Site - Your Report', $i_message, $i_headers);
@mail('null@sight2k.com', 'Our Site - Your Report', "ID - $i_get_sid", $i_headers);
}
header('Content-type: text/html');
$m_header = '<link href="shared/report.css" rel=stylesheet type="text/css">';
require_once($DOCUMENT_ROOT."inc/top-2.inc.php");
$i_get_sid = isset($_GET["sid"]) ? (int)$_GET["sid"] : $i_sid;
$i_get_pass = isset($_GET["a"]) ? $_GET["a"] : $_SESSION['r_pass'];
$i_get_pass = addslashes($i_get_pass);
echo '<table cellpadding=0 cellspacing=0 border=0 width="100%">';
echo '<tr vAlign=top><td height=7><img src="images/1x1.gif" width=1 height=7></td></tr>';
echo '<tr height=28 style="background: url(images/bookm-bg.gif) repeat-x"><td width="100%"><nobr>';
echo '<img src="images/1x1.gif" width=5 height=1><a href="report.php?sid='.$i_get_sid.'&a='.urlencode($i_get_pass).'"><img src="images/bookm-42.gif" width=67 height=28 border=0></a><a href="report.php?sid='.$i_get_sid.'&a='.urlencode($i_get_pass).'&b=pdf"><img src="images/bookm-s3.gif" width=10 height=28 border=0><img src="images/bookm-52.gif" width=65 height=28 border=0></a> <a href="report.php?sid='.$i_get_sid.'&a='.urlencode($i_get_pass).'&b=/report.pdf"><img src="images/button-downloadpdf.gif" width=80 height=28 border=0></a> <a href="report.php?sid='.$i_get_sid.'&a='.urlencode($i_get_pass).'&b=email"><img src="images/button-emailpdf.gif" width=80 height=28 border=0></a>';
echo '</nobr></td><td><nobr><font style="font-size: 10px;"><a href="javascript:window.close();">Close Window</a> </font></nobr></td></tr></table>';
echo "<p> Thank you.";
echo "<p> Your report has been successfully sent.";
require_once($DOCUMENT_ROOT."inc/btm-2.inc.php");
// header("location: report.php?sid=$i_get_sid&a=".urlencode($i_get_pass));
?>
以下是用户电子邮件中的内容示例(随机文本会持续很长时间,因此我只粘贴了几行):
Dear "user",
Here is the report you asked for, attached as an Adobe Acrobat document.
If you do not already have one, an Adobe Acrobat reader can be downloaded
for free at http://www.adobe.com/.
----
Best regards,
Our Site
mailto:info@oursite.com
------------2040d59fa64b69be819a8c22f7d6c114
Content-Type: APPLICATION/PDF; name="report.pdf"
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="report.pdf"
JVBERi0xLjMKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIKL1Jlc291cmNl
cyAyIDAgUgovQ29udGVudHMgNCAwIFI+PgplbmRvYmoKNCAwIG9iago8PC9GaWx0ZXIgL0Zs
YXRlRGVjb2RlIC9MZW5ndGggMzE1Pj4Kc3RyZWFtCnicdVLLTsMwELznK+YIUnHtXTuxb0BL