我已编写此代码以表格格式发送邮件,但它正在发送表格的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>";
mail("subscription@securedentalcare.com, subscription.securedentalcare@gmail.com",$subject,$message,"From: $from\n");
?>
答案 0 :(得分:1)
使用此功能。
$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);
答案 1 :(得分:0)
电子邮件可以作为纯文本或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);
?>
答案 2 :(得分:0)
您需要在标题部分设置Content-Type
,并将From
内容添加到$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);
?>