追加html<;a>;标记


append html <a> tag in php

我正在使用php mail函数

$message.='Hi '.$name.', You have been invited to join this, you can do so by following <a href="https://www.google.com.pk/">This link</a>, '.$text.'';
        $headers = "From: abc@gmail.com" . "'r'n" ."CC: abc@hotmail.com";
        $emailTo = $email;
        $subject = "Invitation email";
        mail($emailTo, $subject, $message, $headers);

它运行得很好,但我使用的<a>要么没有正确添加,要么写得语法不正确,我收到的电子邮件是

你好,您已被邀请加入Maggie,您可以通过关注来做到这一点

 <a
href="http://google.com.pk" class="link"
id="position">this link</a>

,这是要发送的示例电子邮件。

标签是按原样写的,我如何将这个<a>附加到此邮件中?

您需要指定标题。看一看。

$message = "Hello, hope you are doing fine.<br>"
    . "Please check this:<br>"
    . "<a href='"$url-here'">Anchor text</a>";
$headers = 'MIME-Version: 1.0' . "'r'n"
    . 'Content-type: text/html; charset=iso-8859-1' . "'r'n"
    . 'From: youremail@yourdomain.com' . "'r'n";

请为消息使用"(双引号)。

将标题更改为或添加这些

$header.= "MIME-Version: 1.0'r'n"; 
$header.= "Content-Type: text/html; charset=ISO-8859-1'r'n"; 
$header.= "X-Priority: 1'r'n"; 

设置标题可能会有所帮助:

$headers = "Reply-To: FROM_NAME <FROM_EMAIL>'r'n";
$headers.= "From: FROM_NAME <FROM_EMAIL>'r'n";
$headers.='X-Mailer: PHP/' . phpversion();
$headers.= "X-Priority: 3'r'n";
$headers.= "MIME-Version: 1.0'r'n";
$headers.= "Content-type: text/html; charset=iso-8859-1'r'n";

将其放在顶部:

header("Content-Type: text/html");

标题应该包含内容类型。。。$header.="内容类型:text.html;charset=ISO-8859-1''r''n";