在php中以表结构发送邮件
我写了这段代码以表格式发送邮件,但它发送的是我写的表的html标记,而不是表结构在php中以表结构发送邮件,php,Php,我写了这段代码以表格式发送邮件,但它发送的是我写的表的html标记,而不是表结构 <?php $name=$data['name1']; $plann=$data1['plan']; $rate=$data1['rate']; $from =$data['email1']; $subject = "Subscriber's Details" ; $message = "<table>
<?php
$name=$data['name1'];
$plann=$data1['plan'];
$rate=$data1['rate'];
$from =$data['email1'];
$subject = "Subscriber's Details" ;
$message = "<table>
<tr>
<th>Subscriber Name</th>
<th>Selected Plan</th>
<th>Price</th>
</tr>
<tr>
<td>$name</td>
<td>$plann</td>
<td>$rate</td>
</tr>
</table>";
mail("subscription@securedentalcare.com, subscription.securedentalcare@gmail.com",$subject,$message,"From: $from\n");
?>
电子邮件可以作为纯文本或HTML类型发送,默认情况下,使用邮件功能发送的电子邮件将作为纯文本发送,因此不会解析其正文中的HTML标记。尝试将其更改为html类型,然后html标记将被解析
这是固定版本,请尝试以下操作:
<?php
$name=$data['name1'];
$plann=$data1['plan'];
$rate=$data1['rate'];
$from =$data['email1'];
$subject = "Subscriber's Details" ;
$message = "<table>
<tr>
<th>Subscriber Name</th>
<th>Selected Plan</th>
<th>Price</th>
</tr>
<tr>
<td>$name</td>
<td>$plann</td>
<td>$rate</td>
</tr>
</table>";
$headers = "From: " . $from . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; //This line sets the email type to html
mail("subscription@securedentalcare.com, subscription.securedentalcare@gmail.com",$subject,$message,$headers);
?>
您需要在标题部分设置内容类型
,并将从
内容添加到$headers
检查以下代码
<?php
$name=$data['name1'];
$plann=$data1['plan'];
$rate=$data1['rate'];
$from =$data['email1'];
$subject = "Subscriber's Details" ;
$message = "<table>
<tr>
<th>Subscriber Name</th>
<th>Selected Plan</th>
<th>Price</th>
</tr>
<tr>
<td>$name</td>
<td>$plann</td>
<td>$rate</td>
</tr>
</table>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From:" . $from."\r\n";
mail("subscription@securedentalcare.com, subscription.securedentalcare@gmail.com",$subject,$message,$headers);
?>
使用此选项
$name=$data['name1'];
$plann=$data1['plan'];
$rate=$data1['rate'];
$from=$data['email1'];
$subject=“订户详细信息”;
$message=”
订户名称
选定计划
价格
$name
$plann
美元汇率
";
$to=”subscription@securedentalcare.com";
$headers='内容类型:text/html';
邮件($to、$subject、$message、$headers);
你所说的“表格格式”到底是什么意思?电子邮件可以以两种格式发送:纯文本和HTML。我认为,如果邮件中没有适当的提示,将某人的回答记下来也不好。。回答不好并不意味着它无关紧要或不正确。。还有一个小差距,使你的答案突出,所以我通常添加我的答案,然后提示它..一个不好的答案会被否决。答案不一定是不相关或不正确的,否则就不好——如果它只是一段没有注释或其他解释的代码,那么就已经足够糟糕了。
$name=$data['name1'];
$plann=$data1['plan'];
$rate=$data1['rate'];
$from =$data['email1'];
$subject = "Subscriber's Details" ;
$message = "<table><tr>
<th>Subscriber Name</th>
<th>Selected Plan</th>
<th>Price</th>
</tr>
<tr>
<td>$name</td>
<td>$plann</td>
<td>$rate</td>
</tr>
</table>";
$to = "subscription@securedentalcare.com";
$headers = 'Content-type: text/html';
mail($to,$subject,$message,$headers);