如何使用php邮件在邮件正文中发送超链接?

如何使用php邮件在邮件正文中发送超链接?,php,phpmailer,Php,Phpmailer,代码: $to=“萨尔曼。saifi4@gmail.com"; $subject=$subject; $txt=“Name:\t”.strip\u tags($Name)。“\n\n”。“主题:\t”.strip\u tags($Subject)。“\n\n”。“离开日期:\t”。$Leave\u Date。”\n\n.“原因:\t”。strip\u tags($Reason)。“\n\n.strip\u tags(”“”。\n\n.strip\u tags(“”); $headers=“休假申

代码:

$to=“萨尔曼。saifi4@gmail.com";
$subject=$subject;
$txt=“Name:\t”.strip\u tags($Name)。“\n\n”。“主题:\t”.strip\u tags($Subject)。“\n\n”。“离开日期:\t”。$Leave\u Date。”\n\n.“原因:\t”。strip\u tags($Reason)。“\n\n.strip\u tags(”“”。\n\n.strip\u tags(“”);
$headers=“休假申请”;
邮件($to、$subject、$txt、$headers);
我在php中使用simple mail函数,我想发送一个链接,正如我在发送电子邮件时在$txt变量中显示的那样,我的链接如下所示:

$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);

但我只需要a href标签内的文本,即(如果请假申请批准,请单击此处)和(如果请假申请未批准,请单击此处),当我单击文本时,它会在我提到的链接上重定向我。那么,我该怎么做呢?请帮帮我


谢谢

您需要在标题中添加以下内容:

<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=iso-8859-1' . "\r\n";
$text='';
$text.='';
$text.='';
$text.='';

这就是如何在邮件中发送html。您可以在$message变量中设置消息

$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>';
$to=“萨尔曼。saifi4@gmail.com";
$subject=$subject;
$message=”
";
$headers=“MIME版本:1.0”。“\r\n”;
$headers.=“内容类型:text/html;字符集=UTF-8”。“\r\n”;
$headers.='From:'。“\r\n”;
$headers.='Cc:myboss@example.com' . “\r\n”;
邮件($to、$subject、$message、$headers);

我是这两行,但问题相同@Sambhaji Katrajkar您得到的是哪一个问题?
$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);