【问题标题】:How to add hyperlink in mail using PHP如何使用 PHP 在邮件中添加超链接
【发布时间】:2018-05-14 10:40:55
【问题描述】:

我必须在我的邮件功能中添加超链接。但是当已经发送了一封电子邮件时,我没有收到标签,但是像“点击这里”这样的完整代码我只想要一封电子邮件,而没有在我的邮件中看到标签。这是我正在使用的代码:

function stuurMail($email, $verificationCode)
{
    $tekst = "";
    $receiver= $email;
    $topic = "Bevestiging aanmelding EenmaalAndermaal";
    $tekst .= "Bedankt voor uw aanmelding!\nOm gebruik te kunnen maken van het platform, dient u via het onderstaande link uw account te activeren!\n";
    $tekst .= "<a href=\"test_functie.php\">http://test.nl/test.php?check=$verificationCode</a>";
    $header = "From: blabla@gmail.com";
    mail($receiver, $topic, $tekst, $header);
}

【问题讨论】:

  • 研究字符串拼接
  • @ThisGuyHasTwoThumbs 不确定这对这个人有什么帮助。 OP 可以很好地进行字符串连接。有什么问题?
  • @PraveenKumar 他们转义了字符串——这不是串联
  • @ThisGuyHasTwoThumbs 我还是不明白。
  • @PraveenKumar 字符串连接如使用此:echo $my_var. '-' .$another_var :)

标签: javascript php function email


【解决方案1】:

您应该将电子邮件设为 HTML 电子邮件,而不是纯文本电子邮件。以这种方式更新您的标题:

$header = "From: blabla@gmail.com\r\nContent-type: text/html; charset=iso-8859-1";

【讨论】:

  • 谢谢,但我现在知道了 [test_functie.php]test.nl/verificatie.php?check=3FLY2UpY
  • 哇...对不起??
  • 链接无法点击
  • @Emre 尝试将其更改为:$tekst .= "&lt;a href=\"http://test.nl/test.php?check=$verificationCode\"&gt;http://test.nl/test.php?check=$verificationCode&lt;/a&gt;";
  • 或者这样做,因为单引号更快:$tekst .= '&lt;a href="http://test.nl/test.php?check=' . $verificationCode . '"&gt;http://test.nl/test.php?check=' . $verificationCode . '&lt;/a&gt;'; 这可以用于所有代码,记住诸如 "\r\n" 之类的代码总是需要双引号,否则它不会工作..
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多