用PHP发送的电子邮件中的断开链接


Broken link within an email sent with PHP

我遇到了一个奇怪的问题,试图使用php发送电子邮件链接。此链接将使用户进入"更新密码"表单。然而,当我点击这个链接时,它会把我带到浏览器中一个名为"about:blank"的空白页面。我真的不明白为什么会发生这种事……下面是我的代码:链接的html在$msg变量中。

$to     = $email;
$msg    = "Hello $username, your pin # is $pin. Please remember this pin
                because you will need it on the update password form. <br> 
                Please <a href = '"google.com'">click here</a> to be brought to the update password form.";
$header  = 'MIME-Version: 1.0' . "'r'n";
$header .= 'Content-type: text/html; charset=iso-8859-1' . "'r'n";
$header .= 'From: ForgottenPassword@PHPGang.com' . "'r'n" .
                'Reply-To: ForgottenPassword@PHPGang.com' . "'r'n" .
                'X-Mailer: PHP/' . phpversion();    
mail($to,"Forgotten Password",$msg,$header);

我甚至试着把google.com作为目的地,但它仍然给我带来了一个讨厌的问题:空白页面。什么好主意吗?

你需要在你的链接中使用一个完全限定的URL,协议和所有内容。

$msg    = "Hello $username, your pin # is $pin. Please remember this pin
                because you will need it on the update password form. <br> 
                Please <a href = '"http://google.com'">click here</a> to be brought to the update password form.";

尝试如下更改,这里您缺少向url添加HTTP,

<a href = '"google.com'">click here</a>

<a href = '"http://google.com'">click here</a>