dongzhi4498 2012-11-27 02:45
浏览 16
已采纳

发送邮件消息php

i just want to send the order content fetching the result in my database. But when i echo it, it displays it on my php page. i dont want it. I want the content to only appear in the email when the user receive it.

This is my code.

while($row3 = mysqli_fetch_array($result3)){
$addresses=$row3['email'];
$to = $addresses;

$subject = "Order confirmed by Home and decor";



// message
$message = '


<html>
<body>
<table width="500" height="215" border="0">
<tr>
<th width="238" height="211" scope="col"><h1 align="left">Order # 1234</h1></p></th>
<th width="10" scope="col"></th>
<th width="243" scope="col"><p><img src="file:///D|/Programs/xampp/htdocs/images/sitelogo.PNG" width="224" height="68" align="right"></p></th>
</tr>
</table>

<table width="500" height="215" border="0">
<tr>
<th width="181" height="211" scope="col"><p align="left">Ship To:</p>
<p align="left"><?=$row3['first_name']?></p>
<p align="left"><?=$row3['address_1']?></p>
<p align="left"><?=$row3['city']?></p></th>
<th width="80" scope="col"></th>
<th width="40" scope="col"></th>
<th width="181" scope="col"><p align="left"></p>
<p align="right">Bill To:</p>
<p align="right"><?=$row3['first_name']?></p>
<p align="right"><?=$row3['address_1']?></p>
<p align="right"><?=$row3['city']?></p>
</th>
</tr>
</table>

<table width="500" height="94" border="0">
<tr>
<th height="43" scope="col"><div align="left">Order Date:</div></th>
<th scope="col">&nbsp;</th>
<th scope="col">&nbsp;</th>
<th scope="col"><div align="right">Shipping Method:</div></th>
</tr>
<tr>
<th width="126" height="43" scope="col"><div align="left">1/11/13</div></th>
<th width="433" scope="col">&nbsp;</th>
<th width="103" scope="col">&nbsp;</th>
<th width="156" scope="col"><div align="right">BEAST!</div></th>
</tr>
</table>
<table width="500" height="88" border="1">
<tr>
<th width="48" scope="col">Item</th>
<th width="264" scope="col">Product Name</th>
<th width="68" scope="col">Quantity</th>
<th width="92" scope="col">Price</th>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<hr>
<table width="500" height="227" border="0">
<tr>
<th height="43" scope="col">&nbsp;</th>
<th scope="col">&nbsp;</th>
<th scope="col">Subtotal:</th>
<th scope="col">&nbsp;</th>
</tr>
<tr>
<th height="43" scope="col">&nbsp;</th>
<th scope="col">&nbsp;</th>
<th scope="col">Tax:</th>
<th scope="col">&nbsp;</th>
</tr>
<tr>
<th height="43" scope="col">&nbsp;</th>
<th scope="col">&nbsp;</th>
<th scope="col">Shipping:</th>
<th scope="col">&nbsp;</th>
</tr>
<tr>
<th height="43" scope="col">&nbsp;</th>
<th scope="col">&nbsp;</th>
<th scope="col">Discount:</th>
<th scope="col">&nbsp;</th>
</tr>
<tr>
<th width="40" height="43" scope="col">&nbsp;</th>
<th width="278" scope="col">&nbsp;</th>
<th width="68" scope="col">Grand Total:</th>
<th width="96" scope="col">&nbsp;</th>
</tr>
</table>
<p align="right">&nbsp;</p>
</body>
</html>



';



// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";





$headers .= 'From: Order reminder <lol@gmail.com>' . "
";



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


}

Echo is when you want to call something out right. I dont want it to echo, i just want to make the content appear in the email without echoing it.

  • 写回答

4条回答 默认 最新

  • dougongyou7364 2012-11-27 02:54
    关注

    Don't echo your variables, concatenate them into the string. i.e.

    $message = "Some text ".$foo." some more text';
    

    Not:

    $message = "Some text <?=$foo ?> some more text';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥15 统计大规模图中的完全子图问题
  • ¥15 使用LM2596制作降压电路,一个能运行,一个不能
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
  • ¥20 @microsoft/fetch-event-source 流式响应问题
  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式