php - 在 php 中附加 html <a> 标签

标签 php html email

我正在使用 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>进入这封邮件?

最佳答案

您需要指定 header 。看一看。

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

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

关于php - 在 php 中附加 html <a> 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34194933/

相关文章:

javascript - 从 PHP 中返回多个值并在 Javascript 中解析的最佳方法

html - 仅将没有 html 的网页中的文本复制到 Gmail 正文电子邮件中

html - 为什么内联 CSS 仅在打开时更改 html 选定选项的颜色?

java - java邮件API中的message.writeto()和message.getinputstream有什么区别吗?

php - 如果至少有一个属于范围内,如何选择类别中的所有内容

php - Xml 到 Mysql fatal error

php - 学说加密专栏

html - 为什么 span.details 中的边距不起作用?

email - 使用 TLS 发送电子邮件的 Windows 脚本

c# - 在 C# 中使用 ProtonMail 发送电子邮件