簡體   English   中英

Href鏈接在PHP郵件中不起作用

[英]Href link not working in PHP mail

我試圖找到一個解決方案,但是到目前為止,我找不到適合我問題的任何解決方案。

我想向每個新用戶發送注冊郵件,這是我郵件的PHP:

<?php
$message = '<html>
<body>
<p>Hi ' . $fname . ',</br></br>
welcome!</p>
<p>
<a href="\http://www.home.com/en/verification.php?id=' . $db_id . '&code=' . $code . '\">Please click this link</a> to activate your account.</p>
<p>We hope you enjoy our page and are happy to hear about your experiences!</p>
<p>Your team</p>';

$header  = "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html; charset=iso-8859-1\r\n";
$header .= "From: Sender <sender@sender.com>";
$header .= "X-Mailer: PHP ". phpversion();

mail($email, 'Thank you for registering!', $message, $header);
?>

鏈接在我的郵件中無法正常工作。 在Outlook中,我的Href出現在方括號中(例如[ http://www.home.com/en/verification.php?id=4&code=5] ),在Gmail中,僅顯示我的鏈接描述,但我沒有能夠單擊鏈接。

有人可以幫助我嗎?

您的標記不正確:

  • <br/>而不是</br>
  • 您不需要放入html標記
  • 鏈接前后無需放置\\

 <?php $message = '<p>Hi ' . $fname . ',<br/><br/>welcome!</p><p><a href="http://www.home.com/en/verification.php?id=' . $db_id . '&code=' . $code . '">Please click this link</a> to activate your account.</p><p>We hope you enjoy our page and are happy to hear about your experiences!</p><p>Your team</p>'; $header = "MIME-Version: 1.0\\r\\n"; $header .= "Content-type: text/html; charset=iso-8859-1\\r\\n"; $header .= "From: Sender <sender@sender.com>"; $header .= "X-Mailer: PHP ". phpversion(); mail($email, 'Thank you for registering!', $message, $header); ?> 

不需要轉義。

<a href="http://www.home.com/en/verification.php?id=' . $db_id . '&code=' . $code . '">Please click this link</a> to activate your account.</p>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM