这是我尝试在将“购物车”发送给管理员时尝试使用的方法。这可能是一个非正统的方法,请任何建议都会比欢迎。在PHP邮件中包含一个数组的每个循环,如HTML表
此信息来自一个会议,加上一个单独的脚本,它运行良好。它显示了我,然后我试图通过电子邮件发送,以及一些个人信息,购物车的内容:
<?php foreach ($quotes as $quote): ?>
<tr>
<td class="quoteTdL"><h3><?php echo htmlspecialchars($quote['name'], ENT_QUOTES,'UTF-8'); ?></h3></td>
<td class="quoteTdR"><p><?php echo htmlspecialchars($quote['text'], ENT_QUOTES,'UTF-8'); ?></p></td>
</tr>
<?php endforeach; ?>
基本上我想有这个信息在此砍伐邮件脚本:
//send email
$to = "";
$fname = $_REQUEST['fname'] ;
$sname = $_REQUEST['sname'] ;
$email = $_REQUEST['email'] ;
$pnum = $_REQUEST['pnum'] ;
$mnum = $_REQUEST['mnum'] ;
$content = $_REQUEST['content'] ;
$subject = 'Email from SAiGE Longlife website';
$msg = '
<html>
<head>
<title>SAiGE Longlife Decking enquiry</title>
</head>
<body>
<table width="600" border="0" align="center" cellpadding="10">
<tr>
<td colspan="2" align="center" bgcolor="#FF9933" style="font: 18px Arial,Georgia,Serif; color:#fff;">SAiGE Longlife Decking enquiry</td>
</tr>
<tr>
<td width="200" bgcolor="#CCCCCC" style="font: 18px Arial,Georgia,Serif; color:#fff;">Name:</td>
<td width="400" bgcolor="#FF9933" style="font: 18px Arial,Georgia,Serif; color:#000;">';
$msg .=$fname;
$msg .=' ';
$msg .=$sname;
$msg .='
</td>
</tr>
<tr>
<td bgcolor="#CCCCCC" style="font: 18px Arial,Georgia,Serif; color:#fff;">E-mail</td>
<td bgcolor="#FF9933" style="font: 18px Arial,Georgia,Serif; color:#000;">';
$msg .=$email;
$msg .='
</td>
</tr>
<tr>
<td bgcolor="#CCCCCC" style="font: 18px Arial,Georgia,Serif; color:#fff;">Phone numbers:</td>
<td bgcolor="#FF9933" style="font: 18px Arial,Georgia,Serif; color:#000;">';
$msg .=$pnum;
$msg .='
</td>
</tr>
<tr>
<td bgcolor="#CCCCCC"> </td>
<td bgcolor="#FF9933" style="font: 18px Arial,Georgia,Serif; color:#000;">';
$msg .=$mnum;
$msg .='
</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2" bgcolor="#CCCCCC" style="font: 18px Arial,Georgia,Serif; color:#fff;">Message:</td>
</tr>
<tr>
<td colspan="2" bgcolor="#FF9933" style="font: 18px Arial,Georgia,Serif; color:#000;">';
$msg .=$content;
$msg .=$cartHtml;
$msg .='
</td>
</tr>
</table>
</body>
</html>
';
我已经尝试过内爆和整合事情的边缘,但没有运气,并花了很长时间!
是否有可能首先输出循环作为变量,然后包含或不必要?
所有帮助将不胜感激。
非常感谢,
汤姆
杰夫。非常感谢。我很确定我以前也尝试过这种方法,但都无济于事。为了解决这个问题,我不得不将PHP中的HTML分成单独的$ msg。's。我赞赏重新思考! – 2011-03-15 09:50:02
我不明白为什么它不能正常工作,但只要你找到了解决方案,这一切都很好:P – 2011-03-15 13:31:55