0

当用户注册我的网站时,我正在尝试向他们发送一封包含确认码的电子邮件。电子邮件发送正常,但是当我输入完整的 URL 时,邮件没有发送

在这里你可以看到我正在使用的代码:

    $message = 'You have recieved this email because you have signed up to Amped. To complete the registration process, please
click on the link below. <br/> <a href=confirm.php?code=' . $row['emailcode'] . '>Click here to complete registration</a>'

我需要在 confirm.php 之前输入完整的 url 以使链接正常工作,但是当我这样做时,电子邮件不会发送。有任何想法吗?

4

3 回答 3

1

您正在发送相对路径。您需要使用以下命令发送文件的整个路径urlencode

$message = '<a href="' . urlencode("http://www.example.com/confirm.php?") . $row['emailcode'] . '">';
于 2013-03-27T20:42:16.717 回答
0

您缺少引号:

 $message = 'You have recieved this email because you have signed up to Amped. To complete the registration process, please click on the link below. <br/> <a href="confirm.php?code=' . $row['emailcode'] . '">Click here to complete registration</a>'
于 2013-03-27T20:42:33.413 回答
0

您应该确保清理该 url 变量,对其进行编码以安全使用 url,然后在 confirm.php 中对其进行解码。将 db 值直接回显到 url 不是一个好主意。urlencode() 是一个不错的解决方案。不这样做可能会导致 url 中断,进而导致脚本中断。

$code = urlencode($row['emailcode']);

$msg = "stuff.. <a href='http://www.example.con/confirm.php?code=". htmlentities($code) ."'>Click here</a>";
于 2013-03-27T20:46:52.513 回答