代码:
$to = "salman.saifi4@gmail.com";
$subject = $subjects;
$txt = "Name:\t".strip_tags($name)."\n\n"."Subject:\t".strip_tags($subject)."\n\n"."Leave Date:\t".$leave_date."\n\n"."Reason:\t".strip_tags($reason)."\n\n".strip_tags("<a href='http://example.com/confirm.php'>Click Here If Leave Application Approve</a>")."\n\n".strip_tags("<a href='http://example.com/not-confirm.php'>Click Here If Leave Application Not Approve</a>");
$headers = "Leave Application";
mail($to,$subject,$txt,$headers);
我在php中使用简单的邮件功能,我想发送一个链接,就像我在发送电子邮件时显示在$ txt变量中的链接一样,如下所示:
<a href='http://example.com/confirm.php'>click here if leave application approve</a>
<a href='http://example.com/not-confirm.php'>click here if leave application not approve</a>
但是我只想要a href标记内的文本,即(如果不批准请单击此处)和(如果不批准请单击此处),当我单击该文本时,如前所述,它会将我重定向到链接上。所以,我该怎么办?请帮助我。
谢谢
答案 0 :(得分:0)
您需要在标题中添加以下内容:
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
还有,对于文本:
$text = '<html><body>';
$text.= '<a href="http://example.com/confirm.php">click here if leave application approve</a>';
$text.= '<a href="http://example.com/not-confirm.php">click here if leave application not approve</a>';
$text.= '</body></html>';
答案 1 :(得分:0)
这是您可以通过邮件发送html的方法。您可以在$ message变量中设置您的消息
$to = "salman.saifi4@gmail.com";
$subject = $subjects;
$message = "<a href='http://example.com/confirm.php'>click here if leave application approve</a>
<a href='http://example.com/not-confirm.php'>click here if leave application not approve</a>";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <webmaster@example.com>' . "\r\n";
$headers .= 'Cc: myboss@example.com' . "\r\n";
mail($to,$subject,$message,$headers);